• Resolved dulich5

    (@dulich5)


    Dear Sir/Madam,
    I create new post type, such as, teambuilding and having a new post:
    https://dulichokela.com/teambuilding/8-yeu-to-lam-nen-thanh-cong-cua-chuong-trinh-team-building/
    But I visit its cateogry and they’s not found:
    https://dulichokela.com/chuong-trinh-teambuilding/

    Please help me

    ===
    hera is the code I input in function.php

    `function my_cptui_add_post_types_to_archives( $query ) {
    // We do not want unintended consequences.
    if ( is_admin() || ! $query->is_main_query() ) {
    return;
    }

    if ( is_category() || is_tag() && empty( $query->query_vars[‘suppress_filters’] ) ) {
    $cptui_post_types = cptui_get_post_type_slugs();

    $query->set(
    ‘post_type’,
    array_merge(
    array( ‘post’ ),
    $cptui_post_types
    )
    );
    }
    }
    add_filter( ‘pre_get_posts’, ‘my_cptui_add_post_types_to_archives’ );
    function cptui_register_my_cpts_ctteambuilding() {

    /**
    * Post Type: CT Team Buildings.
    */

    $labels = [
    “name” => __( “CT Team Buildings”, “custom-post-type-ui” ),
    “singular_name” => __( “CT Team Building”, “custom-post-type-ui” ),
    “menu_name” => __( “post=teambuling”, “custom-post-type-ui” ),
    “all_items” => __( “all-teambuling”, “custom-post-type-ui” ),
    “add_new” => __( “thêm teambiklding”, “custom-post-type-ui” ),
    “add_new_item” => __( “thêm team”, “custom-post-type-ui” ),
    “edit_item” => __( “s?a team”, “custom-post-type-ui” ),
    “new_item” => __( “thêm teamss”, “custom-post-type-ui” ),
    ];

    $args = [
    “label” => __( “CT Team Buildings”, “custom-post-type-ui” ),
    “labels” => $labels,
    “description” => “sffs”,
    “public” => true,
    “publicly_queryable” => true,
    “show_ui” => true,
    “show_in_rest” => true,
    “rest_base” => “”,
    “rest_controller_class” => “WP_REST_Posts_Controller”,
    “has_archive” => true,
    “show_in_menu” => true,
    “show_in_nav_menus” => true,
    “delete_with_user” => false,
    “exclude_from_search” => true,
    “capability_type” => “ctteam”,
    “map_meta_cap” => true,
    “hierarchical” => true,
    “rewrite” => [ “slug” => “ctteambuilding”, “with_front” => true ],
    “query_var” => true,
    “supports” => [ “title”, “editor”, “thumbnail”, “excerpt”, “custom-fields”, “comments” ],
    “taxonomies” => [ “category”, “post_tag” ],
    ];

    register_post_type( “ctteambuilding”, $args );
    }

    add_action( ‘init’, ‘cptui_register_my_cpts_ctteambuilding’ );

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

Viewing 1 replies (of 1 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Curious if you maybe have some other pre_get_post filtering going on that’s interfering here, as that’s the exact basic instruction that I’d have you try to get this working. So, why it’s not working just yet is odd.

Viewing 1 replies (of 1 total)
  • The topic ‘CPT Archives has not found’ is closed to new replies.