Support » Developing with WordPress » Tag Page not loading any posts

  • Hi,
    I have a cpt in which I have renamed the tag taxonomy to ‘genre’ but the tag pages do not load any posts. I use a child theme and created the cpt via the functions.php file (see code below). I have tried disabling all plugins, resaving permalinks.

    Does anybody have any advice on this?

    Here is the code:

    function child_et_pb_register_posttypes() { $labels = array( 'add_new' => __( 'Add New', 'Divi' ),
        'add_new_item' => __( 'Add New Artist', 'Divi' ),
        'all_items' => __( 'All Artists', 'Divi' ),
        'edit_item' => __( 'Edit Artist', 'Divi' ),
        'menu_name' => __( 'Artists', 'Divi' ),
        'name' => __( 'Artists', 'Divi' ),
        'new_item' => __( 'New Artist', 'Divi' ),
        'not_found' => __( 'Nothing found', 'Divi' ),
        'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
        'parent_item_colon' => '',
        'search_items' => __( 'Search Artists', 'Divi' ),
        'singular_name' => __( 'Artist', 'Divi' ),
        'view_item' => __( 'View Artist', 'Divi' ),
    );
    
    $args = array(
        'can_export' => true,
        'capability_type' => 'post',
        'has_archive' => true,
        'hierarchical' => false,
        'labels' => $labels,
        'menu_icon' => 'dashicons-groups',
        'menu_position' => 50,
        'public' => true,
        'publicly_queryable' => true,
        'query_var' => true,
        'show_in_nav_menus' => true,
        'show_ui' => true,
        'rewrite' => apply_filters( 'et_project_posttype_rewrite_args', array(
        'feeds' => true,
        'slug' => 'artist',
        'with_front' => false,
    )),
    'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
    );
    
    register_post_type( 'project', apply_filters( 'et_project_posttype_args', $args ) );
    
    $labels = array(
        'name' => _x( 'Program Year', 'AMA program year', 'Divi' ),
        'singular_name' => _x( 'Program Year', 'AMA Program Year singular name', 'Divi' ),
        'search_items' => __( 'Search Program Years', 'Divi' ),
        'all_items' => __( 'All Program Years', 'Divi' ),
        'parent_item' => __( 'Parent Program Year', 'Divi' ),
        'parent_item_colon' => __( 'Parent Program Years:', 'Divi' ),
        'edit_item' => __( 'Edit Program Year', 'Divi' ),
        'update_item' => __( 'Update Program Year', 'Divi' ),
        'add_new_item' => __( 'Add New Program Year', 'Divi' ),
        'new_item_name' => __( 'New Program Year Name', 'Divi' ),
        'menu_name' => __( 'Program Years', 'Divi' ),
    );
    
    register_taxonomy( 'project_category', array( 'project' ), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
    ) );
    
    $labels = array(
        'name' => _x( 'Genres', 'Genre name', 'Divi' ),
        'singular_name' => _x( 'Genre', 'Genre singular name', 'Divi' ),
        'search_items' => __( 'Search Genres', 'Divi' ),
        'all_items' => __( 'All Genres', 'Divi' ),
        'parent_item' => __( 'Parent Genre', 'Divi' ),
        'parent_item_colon' => __( 'Parent Genre:', 'Divi' ),
        'edit_item' => __( 'Edit Genre', 'Divi' ),
        'update_item' => __( 'Update Genre', 'Divi' ),
        'add_new_item' => __( 'Add New Genre', 'Divi' ),
        'new_item_name' => __( 'New Genre Name', 'Divi' ),
        'menu_name' => __( 'Genres', 'Divi' ),
    );
    
    register_taxonomy( 'project_tag', array( 'project' ), array(
        'hierarchical' => false,
        'labels' => $labels,
        'show_ui' => true,
        'show_admin_column' => true,
        'query_var' => true,
        'rewrite' => ['slug' => 'genre'],
    ) );
    
    $labels = array(
        'name' => _x( 'Layouts', 'Layout type general name', 'Divi' ),
        'singular_name' => _x( 'Layout', 'Layout type singular name', 'Divi' ),
        'add_new' => _x( 'Add New', 'Layout item', 'Divi' ),
        'add_new_item' => __( 'Add New Layout', 'Divi' ),
        'edit_item' => __( 'Edit Layout', 'Divi' ),
        'new_item' => __( 'New Layout', 'Divi' ),
        'all_items' => __( 'All Layouts', 'Divi' ),
        'view_item' => __( 'View Layout', 'Divi' ),
        'search_items' => __( 'Search Layouts', 'Divi' ),
        'not_found' => __( 'Nothing found', 'Divi' ),
        'not_found_in_trash' => __( 'Nothing found in Trash', 'Divi' ),
        'parent_item_colon' => '',
    );
    
    $args = array(
        'labels' => $labels,
        'public' => false,
        'can_export' => true,
        'query_var' => false,
        'has_archive' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'revisions', 'custom-fields' ),
    );
    
    register_post_type( 'et_pb_layout', apply_filters( 'et_pb_layout_args', $args ) );
    }
    
    function remove_et_pb_actions() {
        remove_action( 'init', 'et_pb_register_posttypes', 15 );
    }
    
    add_action( 'init', 'remove_et_pb_actions');
    add_action( 'init', 'child_et_pb_register_posttypes', 20 );
    • This topic was modified 1 week, 2 days ago by steighne.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    WP doesn’t seem to reliably pick up CPTs with related taxonomy queries. Even though it shouldn’t necessary, I recommend using “pre_get_posts” action to explicitly list all posts types you want involved when a taxonomy query comes through. Easier to do this than trace out where the glitch is 🙂

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.