- This topic has 11 replies, 3 voices, and was last updated 3 years, 2 months ago by
David.
-
AuthorPosts
-
November 8, 2019 at 6:58 am #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:
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
November 8, 2019 at 4:10 pm #1057413Tom
Lead DeveloperLead DeveloperHi 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; } );
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 9, 2019 at 3:38 pm #1058165jonathan
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:
November 9, 2019 at 4:54 pm #1058191Tom
Lead DeveloperLead DeveloperStrange, can you try the updated code here?: https://generatepress.com/forums/topic/entry-title-position-for-custom-post-type/#post-1057413
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 11, 2019 at 2:16 pm #1059938jonathan
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.
November 11, 2019 at 7:57 pm #1060070Tom
Lead DeveloperLead DeveloperThere 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 π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 12, 2019 at 6:48 am #1060415jonathan
No worries, I’ll work it out. Thanks again Tom!
November 12, 2019 at 9:54 am #1060907Tom
Lead DeveloperLead DeveloperNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentNovember 13, 2019 at 1:22 pm #1062369jonathan
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
November 13, 2019 at 3:23 pm #1062441David
StaffCustomer SupportHi 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 π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/November 13, 2019 at 5:37 pm #1062513jonathan
Wow, so the entry title normally maintains the structure? Good catch, thanks David.
November 13, 2019 at 5:42 pm #1062518David
StaffCustomer SupportWell its one thing thats usually guaranteed to be inside that container.
Glad to be of help.Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.