Site logo

Archived topic

Global Post Header Post Terms Taxonomy Not Showing

5 replies · Started by Victor on May 4, 2021

Viewing posts 1–6 of 6

Hey,

So I have cleared my cache. Despite me adding the post terms taxonomy to the global post header and setting the display rule to all posts, it still does not show up on my posts. The Date and author meta is showing though.

Also if I want to show the last updated date in the meta instead of publishing date, how do you change it in the global post header element?

Hi there,

So I have cleared my cache. Despite me adding the post terms taxonomy to the global post header and setting the display rule to all posts, it still does not show up on my posts. The Date and author meta is showing though.

Can you share the exact code added to the Header Element's code area?

Also if I want to show the last updated date in the meta instead of publishing date, how do you change it in the global post header element?

You'll need a shortcode for that.

Check David's shortcode here. https://generatepress.com/forums/topic/how-to-show-the-last-updated-post-date-when-using-page-header-edit-element/

Note: This shortcode only shows the updated date if it exists. If you replace the current template tag that with this shortcode, no date will appear if the post is not modified.

If you want a shortcode that displays the post date but then, automatically changes to updated date if the post is modified, let us know.

<h1>
	{{post_title}}
</h1>
<p class="post-meta">
	{{post_date}} | {{post_author}} | {{post_terms.taxonomy}}
</p>

Yes I would like the code where it displays the post date till its modified then shows modified date.

Thanks

Hi there,

add this PHP Snippet to your site:

function display_modified_date_shortcode () {
    $mod_date = get_the_modified_date();
    if ( get_the_date() !== $mod_date ) {
        return 'Last Updated: ' . $mod_date;
    } else {
        return 'Published: ' . get_the_date();
    }
}
add_shortcode( 'modified_date', 'display_modified_date_shortcode' );

This article explains how to add PHP: https://docs.generatepress.com/article/adding-php/

Then edit your header element and change:

{{post_date}} | {{post_author}} | {{post_terms.taxonomy}}

to:

[modified_date] | {{post_author}} | {{post_terms.taxonomy}}

And check the Execute Shortcodes option in the element.

Thank you so much David sir.

But what about the category not displaying ono the post?

Aah missed that...

So this template tag {{post_terms.taxonomy}} you need to specify which taxonomy.
For Categories you would use: {{post_terms.category}}

This archived topic is closed to new replies.