WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post types querying (5 posts)

  1. syrus69
    Member
    Posted 3 years ago #

    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

  2. beetrootman
    Member
    Posted 3 years ago #

    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'.

  3. syrus69
    Member
    Posted 3 years ago #

    Thanks beetrootman,
    will give it a try

  4. syrus69
    Member
    Posted 3 years ago #

    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

  5. beetrootman
    Member
    Posted 3 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic