Custom WordPress URL

You can use a slug, when you are registering the post type with register_post_type(). You can add this argument like this $labels = array( //… add the labels as you need ) ); $args = array( ‘labels’ => $labels, //add other options as you need ‘rewrite’ => array(‘slug’ => ‘view-promotion’) ); register_post_type( ‘promotion’, $args ); … Read more

How to create a custom template for this custom post type?

Create a File named archive-{yourposttype}.php and Then start tweaking from there. You can style this archive file to your heart’s desire. A very basic template would look like this: <?php get_header(); if(have_posts()) : while(have_posts()) : the_post(); the_title(); echo ‘<div class=”entry-content”>’; the_content(); echo ‘</div>’; endwhile; endif; get_footer(); ?>

How to Display CPT Posts on index Page

Add a function hooked to pre_get_posts which modifies post_type argument of the main query to add your custom post type. function wpd_home_post_types( $query ){ if( $query->is_home() && $query->is_main_query() ){ $query->set( ‘post_type’, array( ‘post’, ‘natural_food’ ) ); } } add_action( ‘pre_get_posts’, ‘wpd_home_post_types’ );