Query custom post type and showing its content

You are not closing the second while loop. You’ll probably want something like this: <?php /* * Template Name: Testimonials */ ?> <?php get_header(); ?> <div class=”container”> <div class=”content-page”> <h1><?php wp_title(); ?></h1> <title><?php wp_title(); ?></title> <?php $query = new WP_Query( array(‘post_type’ => ‘testimonials’, ‘posts_per_page’ => 5 ) ); while ( $query->have_posts() ) : $query->the_post(); ?> … Read more

Custom Post Type – Admin Columns

I’m not sure why you’re getting the ‘0’s. But you shouldn’t be using 2 switch statements in work_custom_columns(). Try this: function work_custom_columns($column){ global $post; switch ($column){ case “work_category”: echo get_the_term_list($post->ID, ‘work_category’, ”, ‘, ‘,”); break; case “work_hashtags”: echo get_the_term_list($post->ID, ‘work_hashtag’, ”, ‘, ‘,”); break; } }

Custom Post Type & Page Template

You should NOT use flush_rewrite_rules when you register your custom post type. Doing so means you will flush permalinks on every page load. Instead you should use the register_activation_hook. Re the template issue: Try renaming the template to single-dossier.php And try changing your register_post_type array to this: register_post_type( ‘dossier’ , array( ‘label’ => __(‘Dossiers’), ‘singular_label’ … Read more

Custom Post Type and Custom Taxonomy not connected

What is your Custom Taxonomy name? Try the following code, replace taxonomy_name with whatever your actual taxonomy name is. $args = array( ‘suppress_filters’ => false, ‘numberposts’ => -1, ‘post_type’ => ‘resource’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘taxonomy_name’, ‘field’ => ‘slug’, //Select taxonomy term by slug( you can also use name/id) ‘terms’ => ‘term-slug/category -slug’, … Read more

Exclude categories For Custom post types

You’d probably be better served by creating a custom taxonomy to accompany your custom post type. That way you can manage terms separate from the built-in categories taxonomy. // Register Custom Taxonomy function wpse_168762_create_gallery_taxonomy() { $labels = array( ‘name’ => _x( ‘Gallery Categories’, ‘Taxonomy General Name’, ‘text_domain’ ), ‘singular_name’ => _x( ‘Gallery Category’, ‘Taxonomy Singular … Read more