• Resolved nspace1999

    (@nspace1999)


    Hello

    can’t get a struture like this

    parent/child/postname

    The plugin gives me only the following structure

    parent/postname

    Here is the code

    function book_tax() {

    // Add new taxonomy, make it hierarchical (like categories)
    $labels = array(
    ‘name’ => __( ‘Secteurs’ ),
    ‘singular_name’ => __( ‘Secteur’ ),
    ‘menu_name’ => __( ‘Secteur’),
    );

    $args = array(
    ‘hierarchical’ => true,
    ‘public’ => true,
    ‘labels’ => $labels,
    ‘show_ui’ => true,
    ‘show_admin_column’ => true,
    ‘query_var’ => true
    );

    register_taxonomy( ‘genre’, ‘book’ , $args );
    }

    add_action( ‘init’, ‘book_tax’, 0 );

    function wpdocs_codex_book_init() {
    $labels = array(
    ‘name’ => _x( ‘Books’, ‘Post type general name’, ‘textdomain’ ),
    ‘singular_name’ => _x( ‘Book’, ‘Post type singular name’, ‘textdomain’ ),
    ‘menu_name’ => _x( ‘Books’, ‘Admin Menu text’, ‘textdomain’ ),
    ‘name_admin_bar’ => _x( ‘Book’, ‘Add New on Toolbar’, ‘textdomain’ ),
    ‘add_new’ => __( ‘Add New’, ‘textdomain’ ),
    ‘add_new_item’ => __( ‘Add New Book’, ‘textdomain’ ),
    ‘new_item’ => __( ‘New Book’, ‘textdomain’ ),
    ‘edit_item’ => __( ‘Edit Book’, ‘textdomain’ ),
    ‘view_item’ => __( ‘View Book’, ‘textdomain’ ),
    ‘all_items’ => __( ‘All Books’, ‘textdomain’ ),
    ‘search_items’ => __( ‘Search Books’, ‘textdomain’ ),
    ‘parent_item_colon’ => __( ‘Parent Books:’, ‘textdomain’ ),
    ‘not_found’ => __( ‘No books found.’, ‘textdomain’ ),
    ‘not_found_in_trash’ => __( ‘No books found in Trash.’, ‘textdomain’ ),
    ‘featured_image’ => _x( ‘Book Cover Image’, ‘Overrides the “Featured Image” phrase for this post type. Added in 4.3’, ‘textdomain’ ),
    ‘set_featured_image’ => _x( ‘Set cover image’, ‘Overrides the “Set featured image” phrase for this post type. Added in 4.3’, ‘textdomain’ ),
    ‘remove_featured_image’ => _x( ‘Remove cover image’, ‘Overrides the “Remove featured image” phrase for this post type. Added in 4.3’, ‘textdomain’ ),
    ‘use_featured_image’ => _x( ‘Use as cover image’, ‘Overrides the “Use as featured image” phrase for this post type. Added in 4.3’, ‘textdomain’ ),
    ‘archives’ => _x( ‘Book archives’, ‘The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4’, ‘textdomain’ ),
    ‘insert_into_item’ => _x( ‘Insert into book’, ‘Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4’, ‘textdomain’ ),
    ‘uploaded_to_this_item’ => _x( ‘Uploaded to this book’, ‘Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4’, ‘textdomain’ ),
    ‘filter_items_list’ => _x( ‘Filter books list’, ‘Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4’, ‘textdomain’ ),
    ‘items_list_navigation’ => _x( ‘Books list navigation’, ‘Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4’, ‘textdomain’ ),
    ‘items_list’ => _x( ‘Books list’, ‘Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4’, ‘textdomain’ ),
    );

    $args = array(
    ‘labels’ => $labels,
    ‘public’ => true,
    ‘publicly_queryable’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘query_var’ => true,
    // ‘rewrite’ => array( ‘slug’ => ‘book’ ),
    ‘capability_type’ => ‘post’,
    ‘has_archive’ => true,
    ‘hierarchical’ => true,
    ‘menu_position’ => null,
    ‘supports’ => array( ‘title’, ‘editor’, ‘author’, ‘thumbnail’, ‘excerpt’, ‘comments’ ),
    );

    register_post_type( ‘book’, $args );
    }

    add_action( ‘init’, ‘wpdocs_codex_book_init’ );

    • This topic was modified 3 years, 10 months ago by nspace1999.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    Hi @nspace1999,

    Thank you for your message.

    I created a clean WordPress installation and added your PHP code to the theme file. And in my opinion everything works, can you please check it?

    The administration panel:

    https://demo-01.gbiorczyk.pl/wp-login.php
    nspace1999
    EwkDS05MNT(1m8O$3yhkYf1h

    FTP:

    s20.mydevil.net (SFTP)
    f1297_nspace1999
    EwkDS05MNT(1m8O$3yhkYf1h

    Path of functions.php file (where I pasted your PHP code):
    /public_html/wp-content/themes/twentytwenty-child/

    The following URL structure works for me:

    What are you set in the following tabs? Please send the screenshots.

    • Settings -> Permalinks -> Common Settings
    • Settings -> WP Better Permalinks

    I will be very grateful for your cooperation. You can do whatever you want on this demo – I’d like to repeat your mistake and then I can fix it.

    Thread Starter nspace1999

    (@nspace1999)

    Hello
    Ok it works.
    The error I had it’s when you assign the parent cat and the child cat at the post creation, it just shows parent/postname.

    Please accept my apologies and i change my review to 5 stars.

    Plugin Author Mateusz Gbiorczyk

    (@mateuszgbiorczyk)

    I am very glad that we managed to reach an agreement. And that everything works.

    For future reference, in case of any plug-ins, please contact the plugin developer first and try to clarify the situation. People are trying really hard and willing to help. And if someone does not help you, then you can evaluate the plugin negatively.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘problem with hierarchical’ is closed to new replies.