Flush rewrite rules when new cpt is registred

Post types are registered on every load. They’re not stored in the database or some other sort of persistent storage. The posts are, but not the post types. So the correct place to flush rewrite rules is when the theme is activated. This can be done with the after_switch_theme hook: add_action( ‘after_switch_theme’, ‘flush_rewrite_rules’ ); For … Read more

Get posts under custom taxonomy and custom post type

You will need to use this code: $the_query = new WP_Query( array( ‘post_type’ => ‘courses’, ‘tax_query’ => array( array ( ‘taxonomy’ => ‘courses_category’, ‘field’ => ‘slug’, ‘terms’ => ‘yourterm’ ) ), ) ); while ( $the_query->have_posts() ) : $the_query->the_post(); // Show Posts … endwhile; You can convert this in shortcode and just append it on … Read more