Title: [Plugin: Display Posts Shortcode] Custom post types, Custom Taxonomies
Last modified: August 20, 2016

---

# [Plugin: Display Posts Shortcode] Custom post types, Custom Taxonomies

 *  Resolved [ekajatik](https://wordpress.org/support/users/ekajatik/)
 * (@ekajatik)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/)
 * Hi there, does it support custom post types and taxonomies, e.g. posts from X
   custom post type, tagged Y from its own custom taxonomy?
 * Thanks
 * [http://wordpress.org/extend/plugins/display-posts-shortcode/](http://wordpress.org/extend/plugins/display-posts-shortcode/)

Viewing 13 replies - 1 through 13 (of 13 total)

 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2229877)
 * Not yet, but it’s on the list of features for the next version
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230138)
 * It currently supports custom post types. use ‘post_type=whatever’
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230165)
 * It also now supports taxonomies: [display_posts taxonomy=”color” tax_term=”blue”]
 *  Thread Starter [ekajatik](https://wordpress.org/support/users/ekajatik/)
 * (@ekajatik)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230166)
 * Hi Bill, does it support both CPT’s and custom taxonomies at the same time, e.
   g. [display_posts post_type=”whatever” taxonomy=”color” tax_term=”blue”] ?
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230167)
 * Yes it does.
 *  Thread Starter [ekajatik](https://wordpress.org/support/users/ekajatik/)
 * (@ekajatik)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230169)
 * Great work Bill, many thanks.
 *  [shane7ny](https://wordpress.org/support/users/shane7ny/)
 * (@shane7ny)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230189)
 * Is there any way to have this use pagination? So that we can have it display 
   100’s of results spread out over pages?
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230190)
 * Unfortunately no, the plugin can’t support pagination since that would interact
   with the actual page’s pagination. Your best bet is to create a template file
   for this, or leverage the existing pagination of WordPress.
 * For instance, if you wanted to have intro text then hundreds of paginated posts
   in the “sample” category, create a template file called “category-sample.php”
   for it and put your content in there. You’d then use /category/sample to access
   it, and /category/sample/page/2 for the second page.
 *  [Christian Kramer](https://wordpress.org/support/users/chriskojak/)
 * (@chriskojak)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230191)
 * Hi Bill, I use your fabulous plugin and it works fine. Now I have a small problem.
   I use tags in a special post type. The argument for the tags is ‘product_tags’,
   the post type is ‘portfolio’.
    Filtering with post_type = “portfolio” works, 
   but for product_tags I have to add the argument ‘product_tags’ to your plugin.
   Here is my solution, that will not work:
 *     ```
       <?php
       /**
        * Plugin Name: Display Posts Shortcode
        * Plugin URI: http://www.billerickson.net/shortcode-to-display-posts/
        * Description: Display a listing of posts using the [display-posts] shortcode
        * Version: 1.5
        * Author: Bill Erickson
        * Author URI: http://www.billerickson.net
        *
        * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
        * General Public License version 2, as published by the Free Software Foundation.  You may NOT assume
        * that you can use any other version of the GPL.
        *
        * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
        * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
        *
        * @package Display Posts
        * @version 1.5
        * @author Bill Erickson <bill@billerickson.net>
        * @copyright Copyright (c) 2011, Bill Erickson
        * @link http://www.billerickson.net/shortcode-to-display-posts/
        * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
        */
   
       // Create the shortcode
       add_shortcode('display-posts', 'be_display_posts_shortcode');
       function be_display_posts_shortcode($atts) {
   
       	extract( shortcode_atts( array(
       		'post_type' => 'post',
       		'tag' => '',
                       'product_tags' => '',
       		'category' => '',
       		'posts_per_page' => '10',
       		'order' => 'DESC',
       		'orderby' => 'date',
       		'include_date' => false,
       		'include_excerpt' => false,
       		'image_size' => false,
       		'taxonomy' => false,
       		'tax_term' => false
       	), $atts ) );
   
       	$args = array(
       		'post_type' => $post_type,
       		'tag' => $tag,
                       'product_tags' => $product_tags
       		'category_name' => $category,
       		'posts_per_page' => $posts_per_page,
       		'order' => $order,
       		'orderby' => $orderby,
       	);
   
       	if ( !empty( $taxonomy ) && !empty( $tax_term ) ) {
       		$tax_args = array(
       			'tax_query' => array(
       				array(
       					'taxonomy' => $taxonomy,
       					'field' => 'slug',
       					'terms' => $tax_term
       				)
       			)
       		);
       		$args = array_merge( $args, $tax_args );
       	}
   
       	$return = '';
       	$listing = new WP_Query($args);
       	if ( $listing->have_posts() ):
       		$return .= '<ul class="display-posts-listing">';
       		while ( $listing->have_posts() ): $listing->the_post(); global $post;
   
       			if ( $image_size && has_post_thumbnail() )  $image = '<a class="image" href="'. get_permalink() .'">'. get_the_post_thumbnail($post->ID, $image_size).'</a> ';
       			else $image = '';
   
       			$title = '<!--<a class="title" href="'. get_permalink() .'">-->'. get_the_title() . '<!--</a>-->';
   
       			if ($include_date) $date = ' <span class="date">('. get_the_date('n/j/Y') .')</span>';
       			else $date = '';
   
       			if ($include_excerpt) $excerpt = ' - <span class="excerpt">' . get_the_excerpt() . '</span>';
       			else $excerpt = '';
   
       			$output = '<li>' . $image . $title . $date . $excerpt . '</li>';
   
       			$return .= apply_filters( 'display_posts_shortcode_output', $output, $atts, $image, $title, $date, $excerpt );
   
       		endwhile;
   
       		$return .= '</ul>';
       	endif; wp_reset_query();
   
       	if (!empty($return)) return $return;
       }
       ?>
       ```
   
 * What is wrong?
 * Thanks for a hint.
 * Best regards,
    CK
 *  [Christian Kramer](https://wordpress.org/support/users/chriskojak/)
 * (@chriskojak)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230192)
 * Find the error: A comma was missing!
 *  Plugin Author [Bill Erickson](https://wordpress.org/support/users/billerickson/)
 * (@billerickson)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230193)
 * product_tags is simply a taxonomy, correct? Use the taxonomy options instead 
   of modifying the plugin. To display the products post type, product_tags taxonomy
   and the blue taxonomy term, use this:
 * `[display-posts post_type="products" taxonomy="product_tags" tax_term="blue"]`
 *  [tbadorrek](https://wordpress.org/support/users/tbadorrek/)
 * (@tbadorrek)
 * [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230233)
 * Bill,
 * Are custom post types now supported? I’m trying to do the following but to no
   avail:
 * [display-posts post_type=”research” taxonomy=”research-categories” tax_term=”
   taxes” include_excerpt=”true” image_size=”thumbnail” posts_per_page=”-1″ ]
 * I’m using “Custom Post Types UI” plugin to create a custom post type, “research”
   and to create a custom taxonomy, “research-categories”, and I have created the
   taxonomy term “taxes” and tagged one of the custom posts. However, nothing appears.
 * Any thoughts on what might be conflicting with the shortcode?
 *  [tbadorrek](https://wordpress.org/support/users/tbadorrek/)
 * (@tbadorrek)
 * [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230234)
 * Nevermind. The plugin only would work when pages were publicly published, not
   privately published.

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘[Plugin: Display Posts Shortcode] Custom post types, Custom Taxonomies’
is closed to new replies.

 * ![](https://ps.w.org/display-posts-shortcode/assets/icon-256x256.jpg?rev=2940963)
 * [Display Posts - Easy lists, grids, navigation, and more](https://wordpress.org/plugins/display-posts-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/display-posts-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/display-posts-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/display-posts-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/display-posts-shortcode/reviews/)

 * 13 replies
 * 5 participants
 * Last reply from: [tbadorrek](https://wordpress.org/support/users/tbadorrek/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-display-posts-shortcode-custom-post-types-custom-taxonomies/#post-2230234)
 * Status: resolved