• Resolved Seath

    (@seath)


    Hello,

    I am having trouble here. I have two CPT and only one have custom taxonomy. When I enable the the rewrite rule for the CPT with custom taxonomy and visit the page I get 404 page. The link looks just as it should but my post doesn’t show up. If I disable the rewrite rules it works just fine.

    This is example of my CTP:

    function create_seath_cpt_stuff () {    
        $labels = array(                
            'name'                  => _x( 'stuff', 'Post type general name', 'seath' ),
            'singular_name'         => _x( 'stuff', 'Post type singular name', 'seath' ),
            'menu_name'             => _x( 'stuff', 'Admin Menu text', 'seath' ),
            'name_admin_bar'        => _x( 'stuff', 'Add New on Toolbar', 'seath' ),
            'add_new'               => __( 'Add New stuff', 'seath' ),
            'add_new_item'          => __( 'Add New stuff', 'seath' ),
            'new_item'              => __( 'New stuff', 'seath' ),
            'edit_item'             => __( 'Edit stuff', 'seath' ),
            'view_item'             => __( 'View stuff', 'seath' ),
            'all_items'             => __( 'All stuffs', 'seath' ),
            'search_items'          => __( 'Search stuffs', 'seath' ),
            'parent_item_colon'     => __( 'Parent stuff:', 'seath' ),
            'not_found'             => __( 'Nothing found.', 'seath' ),
            'not_found_in_trash'    => __( 'Nothing found in Trash.', 'seath' ),
            'archives'              => _x( 'stuff archives', 'seath' ),
        );     
        $args = array(
            'labels'             => $labels,
            'description'        => 'Just stuff.',
            'public'             => true,
            'publicly_queryable' => true,
            'show_ui'            => true,
            'show_in_menu'       => true,
            'query_var'          => true,
            'rewrite'            => array( 'slug' => 'stuff' ),
            'capability_type'    => 'post',
            'has_archive'        => true,
            'hierarchical'       => false,
            'menu_position'      => 6,
            'menu_icon'          => 'data:image/svg+xml;base64,' . base64_encodeff('<svg id="_x31__x2C_5" enable-background="new 0 0 24 24" height="20" viewBox="0 0 24 24" width="20" xmlns="http://www.w3.org/2000/svg"><path style="fill:#fff;" d="m6.75 18c-.192 0-.384-.073-.53-.22-.293-.293-.293-.768 0-1.061l2.719-2.719-2.72-2.72c-.293-.293-.293-.768 0-1.061s.768-.293 1.061 0l3.25 3.25c.293.293.293.768 0 1.061l-3.25 3.25c-.146.147-.338.22-.53.22z"/><path style="fill:#fff;" d="m17.25 18h-4.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h4.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/><path style="fill:#fff;" d="m21.25 23h-18.5c-1.517 0-2.75-1.233-2.75-2.75v-16.5c0-1.517 1.233-2.75 2.75-2.75h18.5c1.517 0 2.75 1.233 2.75 2.75v16.5c0 1.517-1.233 2.75-2.75 2.75zm-18.5-20.5c-.689 0-1.25.561-1.25 1.25v16.5c0 .689.561 1.25 1.25 1.25h18.5c.689 0 1.25-.561 1.25-1.25v-16.5c0-.689-.561-1.25-1.25-1.25z"/><path style="fill:#fff;" d="m23.25 6h-22.5c-.414 0-.75-.336-.75-.75s.336-.75.75-.75h22.5c.414 0 .75.336.75.75s-.336.75-.75.75z"/></svg>'),
            'supports'           => array( 'title', 'editor' ),
            'taxonomies'         => array( '' ),
            'show_in_rest'       => true
        );
        register_post_type('seath_stuff',$args);
    }
    add_action('init', 'create_seath_cpt_stuff', 0);

    And example of my taxonomy:

    function register_taxonomy_for_custom_type() {
            register_taxonomy('seath_stuff_tags',
    		array('seath_stuff'), 
    		array(
                'labels' => array(
                    'name'              => __( 'stuff Tag', 'taxonomy general name', 'seath' ),
                    'singular_name'     => __( 'stuff Tag', 'taxonomy singular name', 'seath' ),
                    'search_items'      => __( 'Search stuff Tags', 'seath' ),
                    'all_items'         => __( 'All stuff Tags', 'seath' ),
                    'parent_item'       => __( 'Parent stuff Tag', 'seath' ),
                    'parent_item_colon' => __( 'Parent stuff Tag:', 'seath' ),
                    'edit_item'         => __( 'Edit stuff Tag', 'seath' ),
                    'update_item'       => __( 'Update stuff Tag', 'seath' ),
                    'add_new_item'      => __( 'Add New stuff Tag', 'seath' ),
                    'new_item_name'     => __( 'New stuff Tag Name', 'seath' ),
                    'menu_name'         => __( 'stuff Tags', 'seath' ),
                ),
                'public'                => true,
                'hierarchical'          => true,
                'show_ui'               => true,
                'show_in_menu'          => true,
                'show_in_rest'          => false,
                'show_admin_column'     => true, 
                'rewrite'               => array( 'slug' => 'stuff-category' ),
                'query_var'             => true,
          )
    	);
    }
    add_action( 'init', 'register_taxonomy_for_custom_type', 0 );

    I have been trying to figure out if I made mistake someplace or whats going on, but I am not having any luck.
    Hope you can help. Thanks.

    • This topic was modified 5 years, 8 months ago by Seath.
Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @seath,

    Thank you for your message.

    I have created a test environment for you. Can you try to recreate your problem there? I will be very grateful!

    Below are the login details:

    https://demo-02.gbiorczyk.pl/wp-admin/
    pckedi
    IB(wr2JV)6ti%Gax*d9APOeg

    Below I am sending you data to FTP (access to the test environment):

    ftps://s20.mydevil.net
    f1297_seath
    IB(wr2JV)6ti%Gax*d9APOeg

    Please try to reproduce your problem and review please me step by step how I can repeat it.

    Thread Starter Seath

    (@seath)

    Sorry for the late reply, just got home from work… I can’t login. Someone must have changed the password.

    Thread Starter Seath

    (@seath)

    AHHHHHH I found the problem. Totally my fault. I didn’t know that the plugin wont work on localhost. I am so embarrassed.
    Sorry and Thanks!

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @seath, please test it anyway in my environment. I would like to make sure everything works.

    Below are the login details:

    https://demo-03.gbiorczyk.pl/wp-admin/
    seath
    IB(wr2JV)6ti%Gax*d9APOeg

    Below I am sending you data to FTP (access to the test environment):

    ftps://s20.mydevil.net
    f1297_seath
    IB(wr2JV)6ti%Gax*d9APOeg
    Thread Starter Seath

    (@seath)

    @mateuszgbiorczyk Done 🙂

    • This reply was modified 5 years, 8 months ago by Seath.
    • This reply was modified 5 years, 8 months ago by Seath.
    • This reply was modified 5 years, 8 months ago by Seath.
    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @seath, have you checked if everything is working properly?

    Thread Starter Seath

    (@seath)

    Yes and looks like it does.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @seath, have you managed to run everything on your environment?

    Thread Starter Seath

    (@seath)

    It works perfectly on my site (online). But it doesn’t work on my localhost (offline).
    But that’s OK I guess, don’t really need it till I go online since I use only dummy content on my localhost anyway.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    @seath, so you are satisfied with how the plug works? Could I ask you to add a review? The reviews help a lot with the promotion and development of the plugin.

    Thread Starter Seath

    (@seath)

    Yes I am 😉 Ofc I will. Thanks for your help.

    Thread Starter Seath

    (@seath)

    Ha! I just noticed that I left you review already 2 years and 4 months ago! That’s how long I have been using your plugin on my other sites.
    Thanks for great work.

Viewing 12 replies - 1 through 12 (of 12 total)

The topic ‘404 on single’ is closed to new replies.