i want to change wordpress post type permalink url for example i have create post type named qproduct and the url ishttpswwwcveoycomqproductbut i want to show item instead qproductand do it progammati
To change the WordPress post type permalink URL, follow these steps:
- Go to your functions.php file in your theme folder.
- Add the following code to create a new post type named 'item':
function create_item_post_type() {
register_post_type( 'item',
array(
'labels' => array(
'name' => __( 'Items' ),
'singular_name' => __( 'Item' )
),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'item'),
)
);
}
add_action( 'init', 'create_item_post_type' );
- Save the changes to the functions.php file.
Now, when you create a new post with the 'item' post type, the permalink URL will be https://www.cveoy.com/item instead of https://www.cveoy.com/qproduct.
Note: If you already have existing posts with the 'qproduct' post type, you will need to update the permalinks by going to Settings > Permalinks and clicking on 'Save Changes' to refresh the URL structure
原文地址: https://www.cveoy.top/t/topic/famA 著作权归作者所有。请勿转载和采集!