Pippins Plugins
  • Email
  • Facebook
  • Feedburner
  • Github
  • Google
  • Twitter
  • Vimeo
  • Youtube
  • Rss
  • About
  • News
  • Join the Site
    • Member Benefits
    • Member Plugins
    • Email Notifications
  • Plugin Store
    • Affiliate Area
    • Checkout
  • Plugins
    • Plugin Portfolio
      • Plugin Portfolio – List View
    • Free
    • Premium
    • Member Plugins
    • Coding Standards
    • Get Plugin Support
  • Tutorials
    • Series
      • Plugin Development 101
      • Creating a User Follow System Plugin
      • Customizing Restrict Content Pro
      • Displaying Content with Easy Content Types
      • Writing Your First WordPress Plugins, Basic to Advanced
      • Working with Widgets
      • User Submitted Image Galleries
      • Plugin Thoughts
      • Integrating Stripe.com with WordPress
      • WordPress Rewrite API
    • Member Exclusive
      • Free Members
      • Subscriber Only
    • Difficulty
      • Beginner
      • Intermediate
      • Advanced
    • Action and Filter Hooks
    • Ajax
    • Custom Post Types
    • External APIs
    • Short Codes
    • Taxonomies
    • Video Tutorials
    • Widget Tutorials
    • WordPress Admin / Dashboard
    • Working with jQuery
    • WordPress Database
    • Writing Plugins
    • Tag Index
  • Reviews
  • Support Forum
  • Contact
    • Support the Site
    • Request Code Review
    • Plugin Support

Listing Custom Post Type Entries with a Short Code

Posted on September 20, 2011 by Pippin in Custom Post Types, Intermediate, Short Codes, Taxonomies, Tutorials 20 Comments
Home» Tutorials » Custom Post Types » Listing Custom Post Type Entries with a Short Code
Tweet
Love It - 3
This entry is part 1 of 8 in the Displaying Content with Easy Content Types Series
Automatically Displaying Meta Field Values in Easy Content Types →
  • Listing Custom Post Type Entries with a Short Code
  • Automatically Displaying Meta Field Values in Easy Content Types
  • Using the Automatic Template Creation System in Easy Content Types
  • Displaying Custom Post Types in Widgetized Sidebars
  • Controlling Page Layouts with Custom Meta Fields
  • Querying Custom Post Types in Your Theme Templates
  • Creating a Simple Events System with Easy Content Types
  • Adding a Simple Image Gallery with the Repeatable Upload Field

Once you have created a custom post type with Easy Content Types, you will want to begin displaying entries from that post type. There are a variety of ways to do it, but one of the easiest by far is using the [ecpt_query] short code included with the plugin. This short code will let you display a list of posts from any post type (including the default posts and pages). It will also let you limit the items displayed, to those filed in a particular taxonomy, or even a particular term within that taxonomy.


Difficulty Level: Easy

The short code, and all of its parameters (with default values) looks like this:

1
[ecpt_query post_type="post" tax="" terms="" number="5"]

This short code can be placed in any page, post, or text widget. So, let’s say you have a custom post type called “books” and you want to list the latest 8 items published; you would do this:

1
[ecpt_query post_type="books" number="8"]

Or, let’s say you want to display the latest 4 books published that are filed under the Fantasy genre (the taxonomy is called “genre” and the term is “fantasy”):

1
[ecpt_query post_type="post" tax="genre" terms="fantasy" number="4"]

If you wanted to include books from the Fantasy and Science Fiction genre, you would use:

1
[ecpt_query post_type="post" tax="genre" terms="fantasy,science-fiction" number="4"]

Notice that the genre names (they’re called Terms) are lower-cased and have spaces replaced with hyphens. This is because we have to use the Term Slug. The slug is the url friendly name of the term. You can find the slug of your term by going to the custom Taxonomy page (in this case, Genres) underneath the main menu item for the post type the taxonomy is attached to, and looking in the “slug” column.

That’s it. Pretty easy.

Tweet Follow @pippinsplugins
custom post type, post types, recent posts, taxonomies, taxonomy

20 comments on “Listing Custom Post Type Entries with a Short Code”

  1. Wout says:
    December 12, 2011 at 5:43 am

    Is there also a front end filter available for this? One that lets your site vistors use 3 or more selectboxes like genre, price (between $10-15, 15-20) and other custom values?
    Backend selection is nice, but front-end selection would make this great!

    Reply
    • Pippin says:
      December 12, 2011 at 8:51 am

      @Wout – No, there isn’t, but you should look at the Query Multiple Taxonomies plugin by Scribu. It’s free from the plugin repository and lets you do exactly that, based off of taxonomy terms.

  2. Michael Penner says:
    December 19, 2011 at 5:51 pm

    Wondering how to get the content of a custom post type to display on a page. Are there more shortcodes available to do this?

    Reply
    • Pippin says:
      December 19, 2011 at 6:00 pm

      @Michael – Do you want to display the complete content of the post type entry?

    • Michael Penner says:
      December 19, 2011 at 7:06 pm

      Yep. Wow, thanks for the fast response!

    • Pippin says:
      December 19, 2011 at 10:43 pm

      No, there is not a short code included with the plugin that will show the full content, but there are definitely some free plugins that will add it one for you.

      You could also look up my tutorial on making “query_posts” short codes.

  3. sami says:
    March 10, 2012 at 3:29 am

    hey ! pipin ur plugin is awesome – there’s a problem when i create custom post there are many attributes for enable/disable title/editor etc….but it doesn’t work for me – when i open custom post for adding new post it shows Title and editor why ? but other things can disabled but not these?

    Thanks

    Reply
    • Pippin says:
      March 10, 2012 at 12:15 pm

      You’re unable to disable the title or editor, but all the others work?

  4. Antonio L Gil says:
    April 7, 2012 at 7:16 pm

    Hello!

    Great plugin! I’m checking the features to buy it, but I have some doubts:

    You can display a list of custom post types filtering on an attribute of Metabox, for example: Show the “events” (or anything else) in 2011.

    And show future events?

    Thanks and Regards!

    Reply
    • Pippin says:
      April 8, 2012 at 9:33 am

      Antonio, I assume you are referring to Easy Content Types (this tutorial is just general WordPress). The short code included with the plugin does not include the ability to list items by a meta value/key, but you can easily do that if you know how to setup your own custom queries with a regular WordPress loop.

  5. Antonio L Gil says:
    April 8, 2012 at 9:57 am

    Hi, sorry, I was referring to Easy Content Types, I think it is incredible plugin.

    Can you write an example of how I should do? Where should I put it?

    Sorry for my English!

    Reply
    • Pippin says:
      April 9, 2012 at 10:40 am

      Are you familiar with the WordPress loop? You are going to have to be in order to do this.

  6. adrian says:
    May 4, 2012 at 1:01 am

    Hey Pippin,

    This works on a normal WP page or post – but when I added it to a text widget, it doesn’t work.
    It showed the shortcode as is instead.

    Any idea why? Using version 2.5.6

    Thanks!

    Reply
    • Pippin says:
      May 4, 2012 at 9:52 am

      Add this:

      add_filter(‘widget_text’, ‘do_shortcode’);

  7. adrian says:
    May 5, 2012 at 11:19 pm

    Thanks Pippin!

    Where do I insert that code? In the theme’s ‘function.php’ file?

    What about the Genesis theme-framework?

    Thanks!

    Reply
    • Pippin says:
      May 6, 2012 at 11:45 am

      functions.php will work just fine, even with Genesis.

  8. Moshe says:
    June 14, 2012 at 7:43 am

    A sort of follow-up to my previous comment. I just noticed the wp-types Types and Views plugins. From what I’ve seen, I like your user-interface and presentation more than theirs, but the functionality of Views seems rather impressive. Can your plugin sync in with Views? Also, do you have any plans to create your own views like plugin?

    One aspect of their plugin that I do like is the ability to quickly create multiple fields for a custom meta box. It’s much quicker than having to create each individual field by itself (check out the video or plugin to see what I mean). Do you think you could include a similar feature in a future update?

    Reply
    • Pippin says:
      June 14, 2012 at 8:45 pm

      I assume you meant to post this on http://pippinsplugins.com/easy-content-types/ ?

      What exactly do you mean “sync with views”? If you’re asking whether Views can add meta fields to post types created in ECPT, then yes, absolutely.

      No, I don’t plan to add that kind of field.

  9. Michel says:
    February 10, 2013 at 9:44 pm

    Pippin,

    What if I want to add a thumbnail to the list?

    Michel

    Reply
    • Pippin says:
      February 11, 2013 at 8:56 pm

      Add thumbnails=”yes” to the short code.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

  • Login

Lost your password?

Please enter your username or e-mail address. You will receive a new password via e-mail.

  • Facebook Become a Fan Like

  • Twitter Subscribe on Twitter Follow

  • YouTube Follow my Videos Subscribe

  • RSS Feed Subscribe with RSS Subscribe

Easy Digital Downloads

Most Loved

  • Love It Pro for WordPress
  • Write a “Love It” Plugin with Ajax to Let Users Love Their Favorite Posts / Pages
  • Simple Notices Pro Plugin for WordPress
  • User Bookmarks for WordPress
  • Front End Registration and Login Forms Plugin

Similar Plugins and Posts

  • Filter Posts by Custom Taxonomy in Admin
  • Post Types Column Editor for WordPress
  • Advanced WordPress Widget Bundle
  • Sugar Modal Windows Plugin
  • Posts By Taxonomy Widget Pro Plugin

Latest Premium Content

  • Plugin Development 101 – Introduction to Adding Dashboard Menus
  • Plugin Development 101 – Intro to Loading Scripts and Styles
  • User Follow System – Part 5
  • Plugin Development 101 – Intro to Short Codes
  • Plugin Development 101 – Registering a Custom Post Type
  • Plugin Development 101 – Intro to Actions

Latest Tutorials

  • Submitting Your First Pull Request to a WordPress Plugin on Github (2)

    Github is an extremely popular tool for managing WordPress plugins, and one...

  • Plugin Development 101 – Introduction to Adding Dashboard Menus (1)

    Adding new menus, both top level and sub level, to the WordPress Dashboard is a really common task for plugins...

  • Plugin Development 101 – Intro to Loading Scripts and Styles (16)

    In this part of Plugin...

Enter your email to receive automated updates when new posts are published

Latest Tweets

  • Shop Front, A simple, free &amp; highly extensible theme for @eddwp http://t.co/0lo6PfnVYE
    May 23, 2013
  • RT @tommcfarlin: Should a #WordPress Plugin Change Post Content? http://t.co/7wt12HO17x
    May 23, 2013
  • RT @chrislema: WordPress Plugin Prices Are Too Low: Even if you were going to trade hours for dollars, which I don&#039;t recommen... http://t.c…
    May 23, 2013

Topics

hook meta box Rémi Corson featured shortcodes campaign monitor add_options_page register_setting Sugar Event Calendar attachments add_shortcode wp_enqueue_script the_content image forms short codes Related posts login do_action authors mail chimp attachment plugin recent posts comments post types bbpress apply_filters short code taxonomies custom post type Ajax images gallery Stripe jquery taxonomy users widgets add_filter easy content types add_action widget restrict content pro easy digital downloads

Weekly Newsletter

Useful Links

  • Join the Site
  • Plugin Store
  • Affiliate Area
  • Tag Index
  • Support the Site
  • Suggest a Tutorial
  • Random Post
  • Contact

Monthly Archives

(c) 2013 Pippin's Plugins