• Resolved bonky18

    (@bonky18)


    I get a 404 error for both term pages and posts. I am working on a local server, here is my CPT and taxonomy

    register_taxonomy('city', array('school'), array(
            'label'                 => 'City',
            'labels'                => array(
                'name'              => 'City',
                'singular_name'     => 'City',
                'search_items'      => 'Find City',
            ),
            'public'                => true,
            'show_in_nav_menus'     => false,
            'show_ui'               => true,
            'show_tagcloud'         => false,
            'hierarchical'          => true,
            'rewrite'               => array('slug'=>'city', 'hierarchical'=>true,),
            'show_admin_column'     => true,
        ) );
    register_post_type('school', array(
            'label'               => 'School',
            'description'         => '',
            'public'              => true,
            'publicly_queryable'  => true,
            'show_ui'             => true,
            'show_in_rest'        => false,
            'rest_base'           => '',
            'show_in_menu'        => true,
            'exclude_from_search' => false,
            'capability_type'     => 'post',
            'map_meta_cap'        => true,
            'hierarchical'        => false,
            'rewrite'             => array( 'slug'=>'school', ),
            'has_archive'         => 'school',
            'query_var'           => true,
            'supports'            => array( 'title', 'editor', 'thumbnail' ),
            'taxonomies'          => array( 'city' ),
        ) );
Viewing 1 replies (of 1 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hello @bonky18,

    Thanks for your message.

    Forgive me for the delay, but I wanted to check it well. I have followed these steps:
    1. I installed the latest version of WordPress.
    2. I pasted your code to the functions.php file. Post Type and Taxonomy were created.
    3. I installed the WP Better Permalinks plugin and set city Taxonomy for school Post Type.
    4. I used the default theme and there was no additional plugin.
    5. I added a new post and assigned a category to it.

    Everything works fine for me. The following URLs point to valid pages:

    • /school/category-01/post-01/
    • /school/category-01/
    • /school/

    Are you sure my plugin is causing the problem? Can you give me some additional information that will help me to repeat this error?

    Best,
    Mateusz

Viewing 1 replies (of 1 total)
  • The topic ‘Get 404 error’ is closed to new replies.