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.
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.
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!
@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.
Wondering how to get the content of a custom post type to display on a page. Are there more shortcodes available to do this?
@Michael – Do you want to display the complete content of the post type entry?
Yep. Wow, thanks for the fast response!
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.
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
You’re unable to disable the title or editor, but all the others work?
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!
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.
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!
Are you familiar with the WordPress loop? You are going to have to be in order to do this.
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!
Add this:
add_filter(‘widget_text’, ‘do_shortcode’);
Thanks Pippin!
Where do I insert that code? In the theme’s ‘function.php’ file?
What about the Genesis theme-framework?
Thanks!
functions.php will work just fine, even with Genesis.
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?
I assume you meant to post this on https://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.
Pippin,
What if I want to add a thumbnail to the list?
Michel
Add thumbnails=”yes” to the short code.
hi pippin,
I use ECPT with wpml plugin with 2 languages and works very well. but when i use shortcode to display my PT that’s show me posts with tow language it’s possible to display one language?
thank you
Which short code are you using?
this one
[ecpt_query post_type=”jurisprudences” number=”8″]
Hi Pippin, I’m working through this with a custom post type of “Repertoire” – I want to display the results in a chart format, and also show some of the meta fields like composer. And I don’t want the results to link to the individual pages for each song. Currently, I’m hand-typing in each piece, as seen here: http://www.thecedarstringquartet.com/repertoire-2. Would you be willing to help me through this? Thank you.
^^ Sorry, /repertoire ^^
That’s quite a bit beyond what I can help with in the scope of this tutorial, sorry. I’d recommend hiring a contractor to assist you.
Hi Pippin,
Will this work with the filter pages available in the squarecode theme or the cr3ative portfolio page templates basically.
So the page templates provide filtering so if I create a index page of items with the shortcode will the filters be able to work.
I think if you use the edd shortcode it gives you some rubbish results, so I’m presuming the page template would have to be rewritten to get the data from the custom posts.
Presumably that could involve rewritting a page template for each… once you’ve done one…
No it won’t, sorry.
Hi Pippin,
I’m looking to use this shortcode to display a Post type ” Speakers”.
IS there a way to style the way the shortcode is displayed? For example: I want to list the post across, and need the image to be 150×150 and have the excerpt show under the image. Is this possible?
Yes it’s possible but you will have to do the custom development to adjust how this displays / styles it.
Ok great! Where do I do all the styling? Is there a default template within the plugin that I can customize?
Not in the plugin. Add your styles to a custom CSS plugin.