custom post type single page

If you have a single page already, you shouldn’t be using a wp_query as well. Instead of these lines: <?php $args = array(‘post_type’ => ‘listing’); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); ?> Use these lines: <?php // Start the loop. while ( have_posts() ) : the_post(); ?>

Some permalinks on Apache/localhost development setup return 404’s when set to anything other than plain permalinks

The slug you use for the CPT looks very weird. You should inspect the rewrite rules being used in parsing a request with something like the query monitor plugin, but the gut feeling is that your CPT slug makes all URLs to match it and since there is no CPT for the URL of a … Read more

Change custom post type permalink according to category

Change your rewrite to add the course query var: ‘rewrite’ => array(‘slug’ => ‘course/%course%’) Then filter post_type_link to insert the selected course into the permalink: function wpa_course_post_link( $post_link, $id = 0 ){ $post = get_post($id); if ( is_object( $post ) ){ $terms = wp_get_object_terms( $post->ID, ‘course’ ); if( $terms ){ return str_replace( ‘%course%’ , $terms[0]->slug … Read more