[Resolved] Adding Page Title via GP Hook

Home Forums Support [Resolved] Adding Page Title via GP Hook

Home Forums Support Adding Page Title via GP Hook

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #235108
    Andy

    Hi Tom,

    I’m trying to dynamically add all page titles except for home page just below the header by adding the following code to the After Header GP Hook:

    <?php if ( ! is_front_page() ) : ?>
    
    <div style="padding: 40px 0;background-color:#34788d;" class="page-banner">
             <div style="padding-left:50px;font-size:1.8em;color:white;" class="grid-container">
                   <?php the_title(); ?>
             </div>
    </div>
    
    <?php endif; ?>

    This is working great except on my portfolio page (set as my blog page) where it already displays the required page title by default (Portfolio) but my code is also adding another title it seems from the first post in the archive.

    Whats the best way around this as I just want the ‘Portfolio’ title displayed.

    URL: http://tinyurl.com/hj7mc59

    #235140
    Tom
    Lead Developer
    Lead Developer

    You might need to update your conditional.

    For example:

    <?php if ( ! is_front_page() && ! is_home() ) : ?>
    
    <div style="padding: 40px 0;background-color:#34788d;" class="page-banner">
             <div style="padding-left:50px;font-size:1.8em;color:white;" class="grid-container">
                   <?php the_title(); ?>
             </div>
    </div>
    
    <?php endif; ?>
    #235234
    Andy

    Working perfectly now thanks.

    I’ve also just noticed another issue, in my customizer settings in Layout>Container I have top content padding set to 0, this seems to be working fine on standard pages as the entry-content class adds a 2em margin.
    However, on single posts there is no padding/spacing at the top of the page: http://tinyurl.com/gurnh64
    Whats the best way to make pages/posts have the same top content padding?.

    #235270
    Tom
    Lead Developer
    Lead Developer

    Why not just add padding to the top in the Customizer?

    #235322
    Andy

    I could but for standard pages there would be more spacing at the top (because of the + 2em margin) then on single posts.

    #235346
    Tom
    Lead Developer
    Lead Developer

    You could always remove that margin when needed:

    .entry-content {
        margin-top: 0;
    }
    #235529
    Andy

    Yeh decided to go with 30px in the customizer then used your CSS for everywhere else.

    #235580
    Tom
    Lead Developer
    Lead Developer
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.