Site logo

Archived topic

Show Date on all Pages (Except Home Page)

3 replies · Started by Fern on November 10, 2020

Viewing posts 1–4 of 4

Hi,

I used the code provided here: https://generatepress.com/forums/topic/show-last-modified-date-to-pagesposts/#post-240919 in order to add the modified date to pages and it works great however, it includes the date on the home page.

Can you please assist me with excluding the home page.

Also, I don't really just want to 'hide' it from the homepage as I have an image that sits directly under the navigation and I think just hiding the date meta will result in a gap between the image and the navigation menu.

Thanks in advance!

Hi,

You can change the code a bit to add !is_front_page() condition.

add_action( 'generate_after_entry_header', 'tu_page_post_meta' );
function tu_page_post_meta()
{ if ( !is_front_page() ) :
	if ( 'page' == get_post_type() ) : ?>
       
		<div class="entry-meta">
			<?php generate_posted_on(); ?>
		</div><!-- .entry-meta -->
	<?php endif;
endif;
}

It works perfectly. Thanks very much!

Nice one.

No problem. :)

This archived topic is closed to new replies.