110 posts
  • Has referred 1000+ members
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has collected 50+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
elemis says

Hello guys,

I’m new to custom post types and don’t know how to display all of the contents of a certain custom post type in a page.

For example if I have a custom post type named “gallery”, and if there are categories under it named “x”, “y”, “z”. I want to have a page like this:

gallery:

x:

  • x-post1
  • x-post2

y:

  • y-post1
  • y-post2

z:

  • z-post1
  • z-post2

I would appreciate any help. Thanks in advance.

1028 posts
  • Has referred 500+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
ThemeBlvd says

When you setup your loop you can just filter it by the post type only, and it’s going to pull all of that custom post type, no matter what the taxonomy is.

So basically, all you’d have to do is put this in your query string:

query_posts('post_type=your-post-type');

(It doesn’t matter if you’re using query posts or not. However, you’re doing your WordPress loop, you just need to use the “post_type” argument in there. )

Sorry now adding to that, I see now what you mean. You want the posts to be separated by your taxonomy terms. If you know what all of your taxonomy terms are, it’s easy. You could just have the loop multiple times and use a different query string:

query_posts('post_type=your-post-type&your-taxonomy=your-current-term');

But if you’re using this like in a theme forest theme, that wouldn’t be a good approach because you don’t know what “categories” the user is going to create. In which case, the answer will get more complicated. So, in your scenario, do you know what x,y,z are? or are you trying to make it so whatever “categories” get created will show?

448 posts Don't be a HATER!
  • Has referred 10+ members
  • Has sold $125,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+5 more
webinpixels says
/** get the taxonomy lists first */
$gallery_taxs = get_terms('gallery', 'orderby=count&hide_empty=0');

foreach( $gallery_taxs as  $gallery_tax){
         query_posts('post_type=your-post-type&gallery='.$gallery_tax->name.'');
/** loop code */
         wp_reset_query();
}

never try this before :D

good luck

110 posts
  • Has referred 1000+ members
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has collected 50+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
elemis says
When you setup your loop you can just filter it by the post type only, and it’s going to pull all of that custom post type, no matter what the taxonomy is.

So basically, all you’d have to do is put this in your query string:

query_posts('post_type=your-post-type');

(It doesn’t matter if you’re using query posts or not. However, you’re doing your WordPress loop, you just need to use the “post_type” argument in there. )

Sorry now adding to that, I see now what you mean. You want the posts to be separated by your taxonomy terms. If you know what all of your taxonomy terms are, it’s easy. You could just have the loop multiple times and use a different query string:

query_posts('post_type=your-post-type&your-taxonomy=your-current-term');
But if you’re using this like in a theme forest theme, that wouldn’t be a good approach because you don’t know what “categories” the user is going to create. In which case, the answer will get more complicated. So, in your scenario, do you know what x,y,z are? or are you trying to make it so whatever “categories” get created will show?

Thank you themeblvd,
Unfortunately I will use this on a template so I don’t know what the categories will be.

110 posts
  • Has referred 1000+ members
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has collected 50+ items on Envato Market
  • Made it to the Authors' Hall of Fame
+5 more
elemis says
/** get the taxonomy lists first */
$gallery_taxs = get_terms('gallery', 'orderby=count&hide_empty=0');

foreach( $gallery_taxs as  $gallery_tax){
         query_posts('post_type=your-post-type&gallery='.$gallery_tax->name.'');
/** loop code */
         wp_reset_query();
}

never try this before :D

good luck

Thank you webinpixels,
Going to try this now :)

by
by
by
by
by
by