WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] get custom category by name and display the custom post_type

[Resolved] get custom category by name and display the custom post_type

  • I have a custom post_type

    register_post_type('specials', $items);
    		register_taxonomy('type', array('specials'), array('hierarchical' => true, 'label' => 'Type', 'singular_label' => 'Type', 'show_ui' => true, 'query_var' => true, 'rewrite' => true));

    I have problem with getting a post from a specific category “type”.

    with <?php query_posts('post_type=specials') ?> i get all the post from the post_type specials, but that is not what i need.

    in the category type i added Item1 and item2, slugname are item-1 , item-2

    i need to get the category/taxonomy of type by slugname (item-1)and then display all the relevant post of it. but i cant find the correct code for it.

    Can someone throw me a good example ?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Bill Erickson
    Participant

    @billerickson

    So you have this setup:
    post type = specials
    taxonomy = type
    taxonomy items = item-1 and item-2

    If you wanted to list all posts “item-1” you could use this:

    query_posts(‘post_type=specials&type=item-1’);

    Does that help?

    Yes! Marvelous! Works like charm <3

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] get custom category by name and display the custom post_type’ is closed to new replies.