0

I have this URL here https://www.gundogworld.co.uk/judge/. I am wishing for this to be a simple archive page. On this page, it has the body class class="archive post-type-archive post-type-archive-tribe_ext_judge logged-in tribe-js I cannot get the /judge to display the archives no matter what I try. mod_rewrite is active on the server, I turned all caching off, visited permalink and re-save after every attempt. in my child theme i have archive-judge.php, single-judge.php and taxonomy-judge.php.

This is the code I have in the plugin where the post is registered, I have turned all plugins off (except the 2 required) and reverted to 2016 I have tried everything I can reading google for 3 weeks with no win!

 /**
     * Set the arguments for and register the post type.
     *
     * @link https://developer.wordpress.org/reference/functions/get_post_type_labels/
     * @link https://developer.wordpress.org/reference/functions/register_post_type/
     *
     * @see Linked_Posts::register_linked_post_type()
     */
    public function register_our_post_type() {
        $post_type_key = self::POST_TYPE_KEY;

        $labels = array(
            'name'                    => esc_html_x( 'Judges', 'Post type general name', 'tribe-ext-judge-linked-post-type' ),
            'singular_name'           => esc_html_x( 'Judge', 'Post type singular name', 'tribe-ext-judge-linked-post-type' ),
            'singular_name_lowercase' => esc_html_x( 'judge', 'Post type singular name', 'tribe-ext-judge-linked-post-type' ),
            // not part of WP's labels but is required by Linked_Posts::register_linked_post_type()
            'add_new'                 => esc_html_x( 'Add New', $post_type_key, 'tribe-ext-judge-linked-post-type' ),
            'add_new_item'            => esc_html__( 'Add New Judge', 'tribe-ext-judge-linked-post-type' ),
            'edit_item'               => esc_html__( 'Edit Judge', 'tribe-ext-judge-linked-post-type' ),
            'new_item'                => esc_html__( 'New Judge', 'tribe-ext-judge-linked-post-type' ),
            'view_item'               => esc_html__( 'View Judge', 'tribe-ext-judge-linked-post-type' ),
            'view_items'              => esc_html__( 'View Judges', 'tribe-ext-judge-linked-post-type' ),
            'search_items'            => esc_html__( 'Search Judges', 'tribe-ext-judge-linked-post-type' ),
            'not_found'               => esc_html__( 'No judges found', 'tribe-ext-judge-linked-post-type' ),
            'not_found_in_trash'      => esc_html__( 'No judges found in Trash', 'tribe-ext-judge-linked-post-type' ),
            'all_items'               => esc_html__( 'Judges', 'tribe-ext-judge-linked-post-type' ),
            'archives'                => esc_html__( 'Judge Archives', 'tribe-ext-judge-linked-post-type' ),
            'insert_into_item'        => esc_html__( 'Insert into judge', 'tribe-ext-judge-linked-post-type' ),
            'uploaded_to_this_item'   => esc_html__( 'Uploaded to this judge', 'tribe-ext-judge-linked-post-type' ),
            'items_list'              => esc_html__( 'Judges list', 'tribe-ext-judge-linked-post-type' ),
            'items_list_navigation'   => esc_html__( 'Judges list navigation', 'tribe-ext-judge-linked-post-type' ),
        );

        $args = array(
            'labels'              => $labels,
            'description'         => esc_html__( 'Judges linked to Events', 'tribe-ext-judge-linked-post-type' ),
            'public'              => true,
            'exclude_from_search' => true,
            'show_in_menu'        => 'edit.php?post_type=' . Tribe__Events__Main::POSTTYPE,
            'menu_icon'           => 'dashicons-businessman',
            'capability_type'     => $post_type_key,
            'map_meta_cap'        => true, // must be true for $this->set_our_capabilities() to take effect
            'supports'            => array(
                'author',
                'editor',
                'excerpt',
                'revisions',
                'thumbnail',
                'title',
            ),
            'has_archive'        => true,
            'rewrite'             => array(
                'slug'       => 'judge',
                'with_front' => false,
            ),
        );

        register_post_type( $post_type_key, $args );
    }

the rewrite rules are as follows

judge/?$    index.php?post_type=tribe_ext_judge other
(.?.+?)(?:/([0-9]+))?/?$    index.php?pagename=$matches[1]&page=$matches[2] page
([^/]+)(?:/([0-9]+))?/?$    index.php?name=$matches[1]&page=$matches[2] post

1 Answer 1

0

I have tested your code and it works just fine. The thing that I think you are missing is flushing the permalinks by going to WP Admin -> Settings -> Permalinks and click Save Changes.

10
  • thank you Vlad, i wish i had £1 for every time i had , flushing the permalinks by going to WP Admin -> Settings -> Permalinks and click Save Changes.!! it must be in the hundreds!!! how would i debug from here? it must be a clash in /judge name in database or a server problem if code works fine for you! doing both is a little out of my comfort zone!!
    – martin
    Commented Jan 28, 2018 at 16:45
  • Sorry I didn't help you. Now I see your CPT has the slug tribe_ext_judge while you say you have archive-judge.php. You should have archive-tribe_ext_judge.php. Maybe this will help. I would also use this rewrite analysis helper plugin (wordpress.org/plugins/rewrite-rules-inspector) to see what https://www.gundogworld.co.uk/judge/ get rewritten to.
    – Vlad Olaru
    Commented Jan 28, 2018 at 18:11
  • thanks vlad , 'has_archive' => true, 'rewrite' => array( 'slug' => 'judge', 'with_front' => false, ), is the slug not renamed to 'judge' ?
    – martin
    Commented Jan 28, 2018 at 18:29
  • That slug is related to the URL slug, not the post type ID or name if you like. It is quite wrong to speak of post type name as slug but it has become somewhat of a habit in the WordPress world, and I am guilty also. So the two are different.
    – Vlad Olaru
    Commented Jan 28, 2018 at 18:36
  • it results in same outcome (archive-tribe_ext_judge.php) , ill have a look at the info you gave above wordpress.org/plugins/rewrite-rules-inspector
    – martin
    Commented Jan 28, 2018 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.