Support » Themes and Templates » How to query an individual custom post

  • 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'
    ); ?>
Viewing 4 replies - 1 through 4 (of 4 total)
  • FYI, if I just to query_posts (‘p=32’); I get nothing.

    Michael

    (@alchymyth)

    Forum Moderator

    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)

    Thanks alchymyth – No joy on those.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to query an individual custom post’ is closed to new replies.