Get ID on the Custom Post Type URL Slug
-
Hello, People .
I created a Custom Post Type Product. My current permalink is https://www.ads-software.com/sample-post/ , but I want my products to have URL like this: https://www.ads-software.com/%post_id%/sample-post/. but the slug is not pulling the ID. It simply goes with https://www.ads-software.com/product/sample-post/ slug.
//Product Post type add_action( 'init', 'product_init' ); function product_init() { $args = array( 'label' => 'Product', 'public' => true, 'show_ui' => true, 'hierarchical' => false, 'query_var' => true, 'taxonomies' => array('category' ), 'rewrite' => array('slug' => $post->ID ), 'has_archive' => true, 'show_in_rest' => true, 'capability_type' => 'post', 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' )); register_post_type( 'product', $args );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Get ID on the Custom Post Type URL Slug’ is closed to new replies.