WordPress

Niestandardowe typy postów nie działają w tym ustawieniu bezpośredniego łącza https://somedominaname.com/%category%/%postname%/ — WordPress Development Stack Exchange

  • 20 lipca, 2023
  • 3 min read
Niestandardowe typy postów nie działają w tym ustawieniu bezpośredniego łącza https://somedominaname.com/%category%/%postname%/ — WordPress Development Stack Exchange


Jeśli w ustawieniach Permalink użyję tej struktury, to przy domyślnym typie postu zostanie to zastosowane →

Ale w przypadku niestandardowych typów postów nie jest ono skutecznie stosowane, a ponadto posty, które były widoczne po zastosowaniu tego ustawienia

dostaje również błędy 404.

 // Lingerie 
  $lingerie_labels = array(
    'name'                  => _x( 'Lingerie ', 'Post type general name', 'notables' ),
    'singular_name'         => _x( 'Lingerie ', 'Post type singular name', 'notables' ),
    'menu_name'             => _x( 'Lingerie ', 'Admin Menu text', 'notables' ),
    'name_admin_bar'        => _x( 'Lingerie ', 'Add New on Toolbar', 'notables' ),
    'add_new'               => __( 'Add New', 'notables' ),
    'add_new_item'          => __( 'Add New Lingerie ', 'notables' ),
    'new_item'              => __( 'New Lingerie ', 'notables' ),
    'edit_item'             => __( 'Edit Lingerie ', 'notables' ),
    'view_item'             => __( 'View Lingerie ', 'notables' ),
    'all_items'             => __( 'All Lingerie ', 'notables' ),
    'search_items'          => __( 'Search Lingerie ', 'notables' ),
    'parent_item_colon'     => __( 'Parent Lingerie :', 'notables' ),
    'not_found'             => __( 'No lingerie found.', 'notables' ),
    'not_found_in_trash'    => __( 'No lingerie found in Trash.', 'notables' ),
    'featured_image'        => _x( 'Lingerie  Cover Image', 'Overrides the “Featured Image” phrase for this post type.', 'notables' ),
    'set_featured_image'    => _x( 'Set cover image', 'Overrides the “Set featured image” phrase for this post type.', 'notables' ),
    'remove_featured_image' => _x( 'Remove cover image', 'Overrides the “Remove featured image” phrase for this post type.', 'notables' ),
    'use_featured_image'    => _x( 'Use as cover image', 'Overrides the “Use as featured image” phrase for this post type.', 'notables' ),
    'archives'              => _x( 'Lingerie  archives', 'The post type archive label used in nav menus.', 'notables' ),
    'insert_into_item'      => _x( 'Insert into post', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post).', 'notables' ),
    'uploaded_to_this_item' => _x( 'Uploaded to this post', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post).', 'notables' ),
    'filter_items_list'     => _x( 'Filter lingerie list', 'Screen reader text for the filter links heading on the post type listing screen.', 'notables' ),
    'items_list_navigation' => _x( 'Lingerie  list navigation', 'Screen reader text for the pagination heading on the post type listing screen.', 'notables' ),
    'items_list'            => _x( 'Lingerie  list', 'Screen reader text for the items list heading on the post type listing screen.', 'notables' ),
    );
  
    $lingerie_args = array(
    'labels'             => $lingerie_labels,
    'public'             => true,
    'publicly_queryable' => true,
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'lingerie' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'menu_icon'          => 'dashicons-admin-post', 
    'show_in_rest'       => true,
    'rest_base'          => 'lingerie',
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'post-formats' ),
    'add_meta_cap'       => true,
    'taxonomies'         => array( 'category', 'post_tag' ),
    );  
    register_post_type( 'lingerie', $lingerie_args );

Jaki jest błąd?

Warto przeczytać!  WordPress - Lista podkategorii i podkategorii podrzędnych, z postami


Źródło