Site logo

Archived topic

Issue generate_entry_meta_post_types and CPT

5 replies · Started by Beate on October 14, 2020

Viewing posts 1–6 of 6

Hello,

I habe created Custom Post Type and output the entry meta with this function:

add_filter( 'generate_entry_meta_post_types', function( $types ) {
    $types[] = 'entwickler-blog';

    return $types;
} );

Issue: The click on the author link leads to "404", although the author had written several articles for this cpt.

Can you help me please?
Regards

Hi David,

thanks for the answer. I have inserted:

add_action( 'pre_get_posts', function( $query ) {
    if ( ! $query->is_main_query() || is_admin() ) {
        return;
    }

    if ( $query->is_author ) {
        $query->set( 'entwickler-blog', array( 'post', 'page' ) );
    }
} );

The error is unfortunately still there. The link to the author still leads to 404.

This line is incorrect:

$query->set( 'entwickler-blog', array( 'post', 'page' ) );

it should be:

$query->set( 'post_type', array('custom_type', 'post') );

Change the custom_type to the your CPT slug.

My mistake is very embarrassing...

Dear David, now it works and I am very grateful for your help!!!

No problems - glad to be of help!

This archived topic is closed to new replies.