Site logo

Archived topic

Entry Title position for Custom Post type

11 replies · Started by jonathan on November 8, 2019

Viewing posts 1–12 of 12

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

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;
} );

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/

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.

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

No problem :)

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

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 :)

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

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

This archived topic is closed to new replies.