Title: Shortcode for Custom Post Type
Last modified: August 19, 2016

---

# Shortcode for Custom Post Type

 *  [parksey18](https://wordpress.org/support/users/parksey18/)
 * (@parksey18)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-for-custom-post-type/)
 * Hi I am having trouble with a shortcode that pulls information from a Custom 
   Post Type. A manage to pull the data, but all of it, however I am only wanting
   to extract a category of the custom post type.
 * **/\* Insiders \*/**
 *     ```
       register_taxonomy('insidersguidecat', 'insidersguide', array('hierarchical' => true, 'label' => __('Insiders Guide Categories'), 'singular_name' => 'Category'));
       }
       add_action('init', 'gr_post_type_insidersguide');
       ```
   
 * **/\* Shortcode \*/** This shortcode draws the information.
 *     ```
       function gr_town($atts, $content = null) {
       extract(shortcode_atts(array(
                       "numposts" => '5',
       	), $atts));
       	query_posts('post_type=insidersguide&showposts='.$numposts);
       ```
   
 * **The code that doesn’t filter the information I want**
 *     ```
       function gr_town($atts, $content = null) {
       extract(shortcode_atts(array(
                       "numposts" => '5',
       		"taxonomy_name" => "term_name"
   
       	), $atts));
       	query_posts('post_type=insidersguide&'.term_name.'&showposts='.$numposts);
       ```
   
 * Any ideas?

The topic ‘Shortcode for Custom Post Type’ is closed to new replies.

## Tags

 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [parksey18](https://wordpress.org/support/users/parksey18/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-for-custom-post-type/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
