1

Please help - I've tried almost everything and I'm absolutely lost!

I'm desperate to get the following permalink structure set up:

ladsholidayguide.com/custom_post/taxonomy/term/postname

For example: ladsholidayguide.com/reviews/venue/clubs/liquid-nightclub

I've tried using the Custom Post Type Permalinks plugin, yet this option doesn't work either

Check this and the custom taxonomy's permalinks will be: www.ladsholidayguide.com/post_type/taxonomy/term/postname/

For some reason

This works fine. ladsholidayguide.com/reviews/venues/junkyard-golf-london/

This doesn't (I get 404) ladsholidayguide.com/reviews/venues/restaurants/imads-syrian-kitchen/

It seems the term / subcategory breaks it.

Below is the code used: If anyone knows how to fix this, please let me know.

/** Custom Post Type Post Type: Reviews: **/

function cptui_register_my_cpts_reviews() {

    $labels = array(
        "name" => __( 'Reviews', '' ),
        "singular_name" => __( 'Review', '' ),
    );

    $args = array(
        "label" => __( 'Reviews', '' ),
        "labels" => $labels,
        "description" => "",
        "public" => true,
        "publicly_queryable" => true,
        "show_ui" => true,
        "show_in_rest" => false,
        "rest_base" => "",
        "has_archive" => true,
        "show_in_menu" => true,
        "exclude_from_search" => false,
        "capability_type" => "post",
        "map_meta_cap" => true,
        "hierarchical" => true,
        "rewrite" => array( "slug" => "reviews", "with_front" => false ),
        "query_var" => true,
        "supports" => array( "title", "editor", "thumbnail" ),
        "taxonomies" => array( "review" ),
    );

    register_post_type( "reviews", $args );
}

add_action( 'init', 'cptui_register_my_cpts_reviews' );


    /** Taxonomy: Review (not reviews due to custom post type name). **/

function cptui_register_my_taxes_review() {

    $labels = array(
        "name" => __( 'Review', '' ),
        "singular_name" => __( 'review', '' ),
    );

    $args = array(
        "label" => __( 'Review', '' ),
        "labels" => $labels,
        "public" => true,
        "hierarchical" => true,
        "label" => "Review",
        "show_ui" => true,
        "show_in_menu" => true,
        "show_in_nav_menus" => true,
        "query_var" => true,
        "rewrite" => array( 'slug' => 'review', 'with_front' => true,  'hierarchical' => true, ),
        "show_admin_column" => false,
        "show_in_rest" => false,
        "rest_base" => "",
        "show_in_quick_edit" => false,
    );
    register_taxonomy( "review", array( "reviews" ), $args );
}

add_action( 'init', 'cptui_register_my_taxes_review' );
0

Maybe that is what you are looking for:

https://wordpress.org/plugins/permalinks-customizer/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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