Site logo

Archived topic

My custom post is not displaying date, author navigation etc like normal posts

11 replies · Started by Pete on June 2, 2018

Viewing posts 1–12 of 12

date, author, categories, tags, navigation

Correct

Great, thanks that works. Is there anyway we can have CPTs displaying this as default rather than having to add this?

Cheers
Pete

It isn't showing the post date?

You can do this:

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

There's no way to do it without the code right now, but I'll look into making it as simple as adding a filter.

Yeah sorry I just realised the above code was for the footer not the header :)

Yea sorry about that - using both functions should handle the header and footer :)

Hi! I was looking for info on how to add meta to CPT's. I read about the possible filter to allow this level of compatibility. Just want to know if this is going to happen or we still have to do it old-school.

BTW can't wait for the new GP 2.2 testing as I understand will bring more Gutenberg options.

There's a filter in GP 2.2 that will allow you to do this:

add_filter( 'generate_entry_meta_post_types', function( $types ) {
    $types[] = 'my-post-type';

    return $types;
} );

add_filter( 'generate_footer_meta_post_types', function( $types ) {
    $types[] = 'my-post-type';

    return $types;
} );

2.2 is a huge update - it's going to need all the beta testing it can get :)

Thank you so much for this Tom! GP is definitely the way to go to develop amazing WordPress sites. I'll help in beta all I can, that's for sure.

Thank you! :)

This archived topic is closed to new replies.