Site logo

[Resolved] Entry Title position for Custom Post type

Home Forums Support [Resolved] Entry Title position for Custom Post type

Home Forums Support Entry Title position for Custom Post type

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1057038
    jonathan

    Hi,

    I’m trying to modify the default GP post layout for a custom post type I’ve created. Nothing dramatic, I just need the entry title to align to the left, to be outside and above the left sidebar and content areas, like this:

    https://prnt.sc/pu9w1q

    I used some functions a few years ago to rip the entry title out and re-add it, but I can’t find the instructions.

    Thanks in advance for any help!

    Jon

    #1057413
    Tom
    Lead Developer
    Lead Developer

    Hi Jon,

    Try this:

    add_action( 'wp', function() {
        if ( 'your-post-type' === get_post_type() ) {
            add_filter( 'generate_show_title', '__return_false' );
        }
    } );

    Then, you can re-hook the title:

    add_action( 'generate_after_header', function() {
        if ( 'your-post-type' === get_post_type() ) :
            ?>
                <div class="header-entry-title grid-container grid-parent">
                    <h1 class="entry-title"><?php the_title(); ?></h1>
                </div>
            <?php
        endif;
    } );
    #1058165
    jonathan

    Hi Tom, thanks for looking into this. This function definitely pulled out the entry title and relocated it. However, it seems to have ripped out all the page content in the process:

    https://ccagp.spin350.com/transactions/shell/

    #1058191
    Tom
    Lead Developer
    Lead Developer
    #1059938
    jonathan

    Thanks again Tom. Is there any way to hook this right before the ID=CONTENT ? I’m trying to get it inside this container so the styling is consistent.

    #1060070
    Tom
    Lead Developer
    Lead Developer

    There isn’t, unfortunately: https://github.com/tomusborne/generatepress/blob/release/2.4/header.php#L60

    Let me see if I can get it added to GP 2.4.0 🙂

    #1060415
    jonathan

    No worries, I’ll work it out. Thanks again Tom!

    #1060907
    Tom
    Lead Developer
    Lead Developer

    No problem 🙂

    #1062369
    jonathan

    Hi Tom,

    One strange thing I noticed. For posts that have no content, for some reason, the left sidebar goes off the viewport.

    https://ccagp.spin350.com/transactions/cip/

    Any idea why? Once I add some text to the post, the layout renders fine.

    thanks,

    Jon

    #1062441
    David
    Staff
    Customer Support

    Hi there,

    the absence of any content causes the Content container to collapse, the sidebar now has freedom to ‘float’ off the edge of the screen.

    This would not normally happen as the content would contain at least the entry title…. best solution is not to leave the post without content 🙂

    #1062513
    jonathan

    Wow, so the entry title normally maintains the structure? Good catch, thanks David.

    #1062518
    David
    Staff
    Customer Support

    Well its one thing thats usually guaranteed to be inside that container.
    Glad to be of help.

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.