WordPress.org

Support

Support » How-To and Troubleshooting » WP_Query not returning what I'd expect.

WP_Query not returning what I'd expect.

  • I’m using this query:

    <?php $featured = new WP_Query(); ?>
    <?php $featured->query('post_type=page&custom-write-panel-id=2&child_of=' . $id); ?>

    All it ever returns is my “Sitemap” page, which is not a child of $id, and is not a write panel. What am I missing?

Viewing 6 replies - 1 through 6 (of 6 total)
  • esmi

    @esmi

    Forum Moderator

    What’s custom-write-panel-id supposed to refer to?

    I’m using Magic Fields which lets you create custom post types called Write Panels. It doesn’t respect the child_of parameter even if I take out the custom-write-panel-id part.

    esmi

    @esmi

    Forum Moderator

    Where are you getting $id from?

    The $id is set in the loop. I’ve echo’d it and it is the ID of the page I’m on.

    esmi

    @esmi

    Forum Moderator

    Try using $post->ID

    Because it’s meta data, you can’t query it using ‘custom-write-panel-id’. Instead, try this:

    <?php $featured = new WP_Query(); ?>
    <?php $featured->query('_mf_write_panel_id=1'); ?>

    You can look in the database table wp-postmeta to find any column names you want to query on.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WP_Query not returning what I'd expect.’ is closed to new replies.