Okay
  Public Ticket #839111
Main Title - Posts
Closed

Comments

  •  1
    Miriam started the conversation

    Hello,

    Up until now I had a site using posts as pages and the Main Title of those posts displayed the post title  - perfect. However I have now added a blog page to display particular posts and now all posts have the Main title & subtitle of the Blog page.

    Is this expected behaviour??

    Example post as page:  http://manatmachine.com/cultivators/  This should have the main title as Cultivators.  This post has the Header setting Display Page Title set to show

    If this is expected behaviour, is it possible to over-ride it by category?  The posts as pages are all in a particular category not displayed on the blog page (http://manatmachine.com/en/blog/)

    Any advice would be welcomed! 


     

  •  1,715
    Barry replied

    Hi Miriam,

    Posts added under the 'Posts' tab in the WordPress admin will always have the blog page title in the header, as it grabs the page title of the 'page_for_posts'. This is the way the theme is built.

    If you really need to display the post title as page title the main-title.php template file needs a slightly edit to achieve that.
    Please navigate to the following path: the-landscaper/parts and edit the 'main-title.php' file.

    Change line 69 from:

    $title = get_the_title( $page_id );

    to: 

    $title = get_the_title();

    Please note that this will affect also the regular blog posts, if you're using that.

    If you have any questions, please let me know.

    Best regards,
    Barry
    QreativeThemes.com  |  WordPress Themes

  •  1
    Miriam replied

    Yes - that's done the trick, thank you!

    It's 99% good now.  Apart from the page that displays blog posts, this now shows the title of the latest blog post.

    Is it possible to edit the template for this page?  Which file is it?

    If not, no worries. Will simply not display title on that one page :)

    Thanks so much for your help and swift reply

    Miriam



  •  1,715
    Barry replied

    Hi Mariam,

    That's requires a couple edits in the file:

    Change line 67 to:

    if ( is_home() ) {

    Add a new elseif() below the first if statement:

    elseif ( is_single() && 'post' === get_post_type() ) {

    $title = get_the_title();

    That should do the trick.

    Please note that when updating the theme the changes will be overwritten. If you want to keep updating the theme in the future you should use install the child theme (which is included in the full download package from ThemeForest) and copy the main-title.php from the parent theme in to the child theme folder in the same folder structure (create a folder named 'parts' in the root of the child theme and paste the main-title.php file in to the parts folder).

    If you have any questions, please let me know.

    Best regards,
    Barry
    QreativeThemes.com  |  WordPress Themes

  •  1
    Miriam replied

    It didn't change the page of blog posts - still displays the latest blog post title instead of the blog page title and it removes the working change made earlier  :(


    I may have misunderstood - 

    This is my code:

    <div class="page-header<?php echo esc_attr( $title_layout ); ?>" <?php echo wp_kses_post( $style_attr ); ?>>
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
    
                    <?php
                        $subtitle = '';
    
                        if ( is_home()) {
                            
                            $title = get_the_title();
                            $subtitle = get_field('subtitle');
                        
                        } elseif ( is_single() && 'post' === get_post_type() ) {
    
                            $title = get_the_title();
    
                        } elseif ( thelandscaper_woocommerce_active() && is_woocommerce() ) {
                            
                            ob_start();
                             woocommerce_page_title();
                             $title = ob_get_clean();
                             $subtitle = get_field( 'subtitle', (int) get_option( 'woocommerce_shop_page_id' ) );
    
                        } elseif ( is_category() || is_tag() || is_author() || is_year() || is_month() || is_day() || is_tax() ) {
    
  •  1,715
    Barry replied

    This one should work ( I changed it from your example ):

    <div class="page-header<?php echo esc_attr( $title_layout ); ?>" <?php echo wp_kses_post( $style_attr ); ?>>
        <div class="container">
            <div class="row">
                <div class="col-xs-12">
    
                    <?php
                        $subtitle = '';
    
                        if ( is_home()) {
                            
                            $title = get_the_title( $page_id );
                            $subtitle = get_field('subtitle');
                        
                        } elseif ( is_single() && 'post' === get_post_type() ) {
    
                            $title = get_the_title();
    
                        } elseif ( thelandscaper_woocommerce_active() && is_woocommerce() ) {
                            
                            ob_start();
                             woocommerce_page_title();
                             $title = ob_get_clean();
                             $subtitle = get_field( 'subtitle', (int) get_option( 'woocommerce_shop_page_id' ) );
    
                        } elseif ( is_category() || is_tag() || is_author() || is_year() || is_month() || is_day() || is_tax() ) {


    Best regards,
    Barry
    QreativeThemes.com  |  WordPress Themes

  •  1
    Miriam replied

    You absolute star!   100% happy now  :)

    ...and looking at your code it became obvious what I had misunderstood - sorry, I'm not well versed in PHP.

    And yes, I am using a child theme as have already hacked about with a couple of templates and added some functions. 

    Thanks again

    Miriam

  •  1,715
    Barry replied

    Great! You're welcome :)

    Best regards,
    Barry
    QreativeThemes.com  |  WordPress Themes