108 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Beta Tester
  • Referred between 500 and 999 users
  • Bought between 50 and 99 items
  • Has been a member for 5-6 years
  • Exclusive Author
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
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Author had a File in an Envato Bundle
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 4-5 years
  • Referred between 500 and 999 users
+1 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?

436 posts Don't be a HATER!
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Bought between 10 and 49 items
  • Referred between 10 and 49 users
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Has been a member for 4-5 years
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

108 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Beta Tester
  • Referred between 500 and 999 users
  • Bought between 50 and 99 items
  • Has been a member for 5-6 years
  • Exclusive Author
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.

108 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Beta Tester
  • Referred between 500 and 999 users
  • Bought between 50 and 99 items
  • Has been a member for 5-6 years
  • Exclusive Author
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