Site logo

Archived topic

How to edit the meta (authorname, category, date etc) for posts?

1 reply · Started by Sascha on November 17, 2020

Viewing posts 1–2 of 2

Hi,

I have created some CPT via "Pods" and now would like some of them displayed incl. their standard meta, others only "Date Modified":

CPT "academy": no meta at all
CPT "support": Only "date modified"
Blog Post Type: Only "date modified" & "category"

on top of each post, and "category" & "tags" below each post for each CPT.

I have seen this doc-page about "generate_entry_meta_post_types", but not able to modify this in order to make it work here. is this the correct snippet anyway? If not, what's that for?

And how to accomplish the above mentioned requirements?

Thank you and kind regards,
Sascha

Hi there,

No meta at all should be the default for custom post types.

To enable post meta on your support cpt, you can do this:

add_filter( 'generate_entry_meta_post_types', function( $types ) {
    $types[] = 'support';

    return $types;
} );

Now we can tell the support cpt to only display the date:

add_filter( 'generate_header_entry_meta_items', function( $items ) {
    if ( 'support' === get_post_type() ) {
        $items = array(
            'date',
        );
    }

    return $items;
} );

Let me know if this helps or not :)

This archived topic is closed to new replies.