Custom Slug in Custom Post Types and Custom Taxonomies

Question

We never ever get into this situation because I will never use custom post types in a blog article website.

But, because SEO and Analytics we need to change this.

this my example:

 $postTypeName = 'articles';
 
 $postTypeArgs = [
        'label'                => __('Articles', 'll'),
        'description'          => __('Articles', 'll'),
        'labels'               => $postTypeLabels,
        'supports'             => ['title', 'editor','author', 'excerpt', 'thumbnail', 'revisions'],
        'register_meta_box_cb' => isset($postTypeMetaboxesCallback) ? $postTypeMetaboxesCallback : NULL,
        'hierarchical'         => FALSE,
        'public'               => TRUE,
        'show_ui'              => TRUE,
        'show_in_menu'         => TRUE,
        'show_in_nav_menus'    => TRUE,
        'show_in_admin_bar'    => TRUE,
        'taxonomies'            => [$taxonomyName],
        'menu_position'        => 5,
        'menu_icon'            => 'dashicons-admin-post',
        'can_export'           => TRUE,
        'has_archive'          => $postTypeSlugPlural,
        'capability_type'       => 'post',
        'show_in_rest' => TRUE,
        'exclude_from_search'  => FALSE,
        'publicly_queryable'   => TRUE,
        'rewrite'              => [
            'slug'          => $postTypeName/%year%/%monthnum%/%day%/%custom_taxonomy%/%postname%,
            'with_front'    => TRUE
        ],
    ];
 
    flush_rewrite_rules();
    register_post_type($postTypeName, $postTypeArgs);

how can I achieve the slug?

/articles/%year%/%monthnum%/%day%/%custom_taxonomy%/%postname%

is this possible?

0
Locke 2 months 0 Answers 9 views 0

Leave an answer