This topic has 7 replies, 2 voices, and was last updated 6 years by Radu.

  • Author
  • #195891
     alexplex86
    Participant

    Hello! How can I disable the page title in page.php? I tried setting $title_arr[‘show_title’] = true; to false but nothing happens.

    I don’t want to use the CSS display: none

    #195922
     Radu
    Moderator

    Hi,

    You want to remove completely page title ? from all pages/posts/cpt ? or in certain page ?

    Did you had checked the page backend ? see the screenshot

    Cheers
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #195984
     alexplex86
    Participant

    Sorry, I was being unclear. I’m editing another plugin and this plugin does not have any options for hiding the page title. So I took the PHP code from Kleos page and in that code I found some hooks. I was just wondering what hook I need to edit so that the title wont be displayed.

    Attachments:
    You must be logged in to view attached files.
    #196148
     Radu
    Moderator

    Hi,

    You will have to ask the plugin author for a conditional tag like this if_plugin_page() and if they have one you will have to use a code like this

    COPY CODE
    
    add_action( 'after_setup_theme', 'hide_the_tile_certain_places', 10 );
    function hide_the_tile_certain_places() {
        //title section
        $title_arr['show_title'] = true;
    
        //hide breadcrumb?
        $title_arr['show_breadcrumb'] = false;
    
    }
    
    

    wrap the add action in the plugin condition

    Cheers
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #196152
     alexplex86
    Participant

    Thanks! I’ll try that!

    #196159
     Radu
    Moderator

    Let me know

    btw what’s the plugin name ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #196163
     alexplex86
    Participant

    It’s Modern Events Calendar. This plugin automatically generates an individual page for every event that is posted with its own elements that I didn’t want to use. I only wanted to display my own content on those pages. That was not possible without customizing the plugin. So I pasted the code from Kleos page.php into Modern Events Calendars single-mec-events.php and got what I wanted.

    Except that Kleos page.php by default shows the title. And there was no option for disabling this title in the Modern Events Calendar admin panel.

    So I looked around and found the $title_arr[‘show_title’] hook or function or snippet or whatever it is called and thought maybe if I pasted it inside single-mec-events.php and set it to false it might disable the title.

    But that did nothing. So as of now I just used display:none. But I read somewhere that you should avoid using display:none as much as possible. But I don’t know why. Also, display:none disables the title on the whole site, even on pages where I do want to use titles.

    I’m pretty new to coding and PHP so I might not know what I am doing 😛

    #196177
     Radu
    Moderator

    Hi,

    Found a easy way just copy this file : wp-content/themes/kleo/page-parts/general-title-section.php to your child theme in wp-content/themes/kleo-child/page-parts/

    Create the missing folders in child theme.

    Then open from child theme wp-content/themes/kleo-child/page-parts/general-title-section.php and add the next code in the marked area starting from line 23-24

    COPY CODE
    
    
    /*Hide the tittle on events pages*/
    
    if(is_singular('post')){
        $title_arr['show_title'] = false;
        //$title_arr['show_breadcrumb'] = false;
        //$title_arr['extra'] = '';
    }
    
    /*END Hide the tittle on events pages*/
    
    

    Replace post from the code with your post type slug.

    It should be ok.

    Cheers
    R

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 8 posts - 1 through 8 (of 8 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?