CPT Template Not Showing – Getting 404

Always flush the rewrite rules when you register a new public post type or taxonomy. Otherwise the internal rewrite rules will not take that into account when an URL is mapped to a query. You can automate that process by hooking into registered_post_type and registered_taxonomy. Below is the updated code, based on feedback from comments … Read more

URL Rewrite Adjustment for Custom Post Type causes template to revert to index.php

The issue is that %month% isn’t a recognized rewrite tag. If you add the tag within your init action and flush permalinks, the query will succeed. function register_story_post_type(){ // your post type registration stuff here, and then… add_rewrite_tag( ‘%month%’,'([^&]+)’ ); } add_action(‘init’,’register_story_post_type’); There are also about a hundred ways you could otherwise clean up that … Read more

How to display custom taxonomy

Once you have created custom taxonomies in WordPress, the next step is to display them on post pages. Fortunately, this is a matter of adding the following single line of code to the single.php (located in the theme folder): <?php the_terms( $post->ID, ‘topics’, ‘Topics: ‘, ‘, ‘, ‘ ‘ ); ?> By default custom taxonomies … Read more

Loading custom page template on a one page website

add_filter( ‘template_include’, ‘wpsites_home_page_template’, 99 ); function wpsites_home_page_template( $template ) { if ( is_singular( ‘page’ ) ) { $new_template = locate_template( array( ‘single_page-template.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; } You should be able to tweak something like this to get it to do what you … Read more