Support » Plugin: WP Better Permalinks » problem with hierarchical

  • Resolved naghneh

    (@naghneh)


    hi Mateusz
    I read all of your topics but don’t find any solution to my problem.
    my problem like this topic:
    https://wordpress.org/support/topic/problem-with-hierarchical-2/

    this in my child term URL that perfectly worked: /cancer/breast-cancer/introduction/
    but when I load my post URL changed to: /cancer/breast-cancer/post_slug/
    it’s mean to a removed introduction from my single post URL

    my code for creating post_type and taxonomy:

    function s7n_post_type() {
    
    	$labels = array(
    		'name'               => _x( 'سرطان‌ها', 'Post Type General Name', '4c' ),
    		'singular_name'      => _x( 'سرطان', 'Post Type Singular Name', '4c' ),
    		'menu_name'          => __( 'سرطان‌ها', '4c' ),
    		'parent_item_colon'  => __( 'پدر سرطان', '4c' ),
    		'all_items'          => __( 'همه‌ی سرطان‌ها', '4c' ),
    		'view_item'          => __( 'نمایش سرطان', '4c' ),
    		'add_new_item'       => __( 'افزودن سرطان جدید', '4c' ),
    		'add_new'            => __( 'افزودن سرطان جدید', '4c' ),
    		'edit_item'          => __( 'ویرایش سرطان', '4c' ),
    		'update_item'        => __( 'بروزرسانی سرطان', '4c' ),
    		'search_items'       => __( 'جستجوی سرطان', '4c' ),
    		'not_found'          => __( 'یافت نشد', '4c' ),
    		'not_found_in_trash' => __( 'در زباله یافت نشد', '4c' ),
    	);
    	$args   = array(
    		'label'               => __( 'سرطان‌ها', '4c' ),
    		'description'         => __( 'سرطان‌ها', '4c' ),
    		'labels'              => $labels,
    		'supports'            => array( 'title', 'editor', 'custom-fields' ),
    		'hierarchical'        => true,
    		'public'              => true,
    		'show_ui'             => true,
    		'show_in_menu'        => true,
    		'show_in_nav_menus'   => true,
    		'show_in_admin_bar'   => true,
    		'menu_position'       => 5,
    		'menu_icon'           => 'dashicons-groups',
    		'can_export'          => true,
    		'has_archive'         => true,
    		'exclude_from_search' => true,
    		'publicly_queryable'  => true,
    		'capability_type'     => 'post',
    		'show_in_rest'        => true,
    		'rewrite'             => array(
    			'slug' => 'cancer'
    		)
    
    	);
    	register_post_type( 'cancer', $args );
    
    }
    
    function s7n_taxonomies() {
    	$labels = array(
    		'name'              => _x( 'انواع سرطان', 'taxonomy general name', '4c' ),
    		'singular_name'     => _x( 'سرطان', 'taxonomy singular name', '4c' ),
    		'search_items'      => __( 'جستجوی سرطان ها', '4c' ),
    		'all_items'         => __( 'همه سرطان ها', '4c' ),
    		'parent_item'       => __( 'سرطان پدر', '4c' ),
    		'parent_item_colon' => __( 'پدر سرطان:', '4c' ),
    		'edit_item'         => __( 'ویرایش سرطان', '4c' ),
    		'update_item'       => __( 'بروزرسانی سرطان', '4c' ),
    		'add_new_item'      => __( 'افزودن سرطان جدید', '4c' ),
    		'new_item_name'     => __( 'نام سرطان جدید', '4c' ),
    		'menu_name'         => __( 'انواع سرطان', '4c' ),
    	);
    	$args   = array(
    		'hierarchical'      => true,
    		'labels'            => $labels,
    		'show_ui'           => true,
    		'show_admin_column' => true,
    		'query_var'         => true,
    		'show_in_rest'      => true,
    		'rewrite'           => array(
    			'slug'         => 'cancer_type',
    		)
    	);
    	register_taxonomy( 'cancer_type', array( 'cancer' ), $args );
    }
    
    add_action( 'init', 's7n_post_type', 0 );
    
    add_action( 'init', 's7n_taxonomies', 0 );
Viewing 1 replies (of 1 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hello @naghneh,

    Thanks for your message.

    Does that mean “introduction” in the URL? What is this? Can you describe the parts of your original URL structure?

    Best,
    Mateusz

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.