Sujeet
Sujeet

Reputation: 1800

how to add a new post type and fetch all the post related to it in wordpress?

I want to add a new post type for example news in the admin and get the post related to it . How can we do it in wordpress? Do i have to add a plugin ? Any help would be highly appreciated.

Upvotes: 0

Views: 60

Answers (1)

Nikolay Yordanov
Nikolay Yordanov

Reputation: 1404

See the docs for register_post_type() and register_taxonomy(). Then you can use query_posts:

query_posts(array(
    'post_type' => 'YOUR POST TYPE',
    'taxonomy' => 'YOUR TAXONOMY FOR THE POST TYPE', 
    'terms' => $array_of_categories,
    'orderby' => 'menu_order', 
    'order' => 'ASC'
));

Upvotes: 2

Related Questions