WordPress.org

Ready to get started?Download WordPress

Forums

How to query an individual custom post (5 posts)

  1. robahas
    Member
    Posted 2 years ago #

    Hi - I'm having trouble constructing this query. The idea is to grab a particular post, which also happens to be a custom post. So I'm trying this, but it's obviously wrong. It just lists all the custom posts. How do I limit to just one particular custom post? Thanks

    <?php query_posts(  array(
    'post_type' => 'columns'
    ),
    'p=32'
    ); ?>
  2. robahas
    Member
    Posted 2 years ago #

    FYI, if I just to query_posts ('p=32'); I get nothing.

  3. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    you could try:

    <?php query_posts(  array(
    'post_type' => 'columns',
    'p' => 32 )
    ); ?>

    or:

    <?php query_posts(  array(
    'post_type' => 'columns',
    'post__in' => array(32) )
    ); ?>

    (untested)

  4. robahas
    Member
    Posted 2 years ago #

    Thanks alchymyth - No joy on those.

  5. robahas
    Member
    Posted 2 years ago #

    Update - I must have done something wrong the first time bc your first suggestion does work. Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic