Site logo

Archived topic

Showing Author and Published Date on CPT

1 reply · Started by Satori on January 31, 2018

Viewing posts 1–2 of 2

Hi! A few weeks ago Tom provided this code to show the posts navigation, category and tags on my CPT entries.

add_action( 'generate_after_entry_content', 'tu_cpt_footer_meta' );
function tu_cpt_footer_meta() {
    if ( is_singular( 'your-post-type' ) ) : ?>
        <footer class="entry-meta">
            <?php generate_entry_meta(); ?>
            <?php generate_content_nav( 'nav-below' ); ?>
        </footer><!-- .entry-meta -->
    <?php endif;
}

The thing is, I don't why I forgot about it, but I also need to display the published date and author, just as a default post. Can you help me with the code?

Also, as I'm using two CPT's, you provided a solution to include both of them, is the next:

is_singular( array( 'resena', 'critica' ) )

But that breaks my website, there is an alternative?

You could do this:

add_action( 'generate_after_entry_title', 'tu_cpt_post_meta' );
function tu_cpt_post_meta() {
	if ( is_singular( 'your-post-type' ) ) : ?>
		<div class="entry-meta">
			<?php generate_posted_on(); ?>
		</div><!-- .entry-meta -->
	<?php endif;
}

What about your website breaks? Any specific errors?

This archived topic is closed to new replies.