Archived topic
Change place of post title and keep menu collapsed
5 replies · Started by Gabriela on November 2, 2020
Hi there,
Two questions:
1. I am trying to place the gallery post title so that it displays below the gallery (I have marked it with {{post_title}} here: https://danielaschneider.com.br/portfolio/artur-alvim/ ). So I created a Layout Element for that type of post disabling the Post title. And I think I can enable it where I want with a Hook Element. Am I right? What arguments shall I put in that hook?
2. I want the Menu to remain collapsed when I open the Portfolio page (it’s empty for now).
Thank you!
Hi there,
there are no Hooks within the Post/Page Content, as you have added the gallery to the page content you would have to also add your own H1 title to the content.
Hi,
But the title is given by the album itself (the plugin creates the post with the album inside). My client won’t have access to a post to edit it. I need to facilitate to my client. I should create a template to have that result? Hooks can’t handle the post title?
Hi,
Since, there's no hooks to place your post title within the content we can do a workaround by making a shortcode we can place within the content to serve as our dynamic "hook".
You can make a shortcode that lets you display your post title anywhere you want.
Here's an example:
add_shortcode( 'post_title', function() {
ob_start();
// Start your PHP below
echo '<h1 class="sh-post-title">'.get_the_title().'</h1>';
// End your PHP above
return ob_get_clean();
} );
You can then display your page/post title by using the shortcode [post_title] anywhere within the content.
Perfect!
Thank you!
Nice one.
No problem. :)