WordPress.org

Support

Support » Plugins and Hacks » Custom Post types querying

Custom Post types querying

  • syrus69

    @syrus69

    hi guys,
    i have added custom post types(CPT) via UI plug-in,
    and would like to know how i can divide the CPT from the regular posts?
    for example my CPT are products (i.e parts) and i would like the home page to display the normal blog post’s i.e news and updates
    and i would like a separate section for the latests CPT
    i tried doing this i get both CPT and normal posts in the same section.

    also would like to add the CPT to the recent post’s widget

    any help would be greatly appreciated

Viewing 4 replies - 1 through 4 (of 4 total)
  • beetrootman

    @beetrootman

    Hi, can’t pm so I’ll explain here. In order to separate different types of posts you need a custom template.

    You would make a page called products, then make template called products.php and set that page to use it.
    Inside that template before:
    <?php if (have_posts()) : ?>
    You would put:
    <?php query_posts(‘post_type=product’); ?>
    Which means only product type posts are displayed.

    Try searching for ‘page templates’ and ‘query_posts’.

    syrus69

    @syrus69

    Thanks beetrootman,
    will give it a try

    syrus69

    @syrus69

    that worked a treat thanks,
    in order to display them separately on the Home page i would need 2 loops on the home page right ?
    one with the normal post and the other with CPT
    is that correct

    beetrootman

    @beetrootman

    Yes I believe so, although I’ve never done it myself. It’s explained in the codex though, under loop.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Post types querying’ is closed to new replies.