'rewrite' => array('slug' => '/video/%year%/%monthnum%/%post_id%/', 'with_front' => FALSE) This will solve your problem, and don't forget to goto [Settings -> Permalinks] and Save the changes for taking effect.
wordpress permalink set while create a custom post using code "register_post_type"
-
22-07-2023 - |
سؤال
I have tried with set permalink when create a custom post: permalink structure "custom_post_name/year/month/post-id".
i have tried some following code but not work
add_action( 'init', 'video' );
function video() {
register_post_type( 'video',
array(
'labels' => array(
'name' => 'Video',
'singular_name' => 'video',
'add_new' => 'Add New',
'add_new_item' => 'Add New',
'edit' => 'Edit',
'edit_item' => 'Edit',
'new_item' => 'New',
'view' => 'View',
'view_item' => 'View',
'search_items' => 'Search',
'not_found' => 'No Video found',
'not_found_in_trash' => 'No Videos found in Trash',
'parent' => 'Parent'
),
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor' ),
'rewrite'=>array('slug'=>'/video/%year%/%monthnum%/%post_id%/'),
'has_archive' => true
)
);
}
المحلول
لا تنتمي إلى StackOverflow