WordPress.org

Ready to get started?Download WordPress

Forums

WP_Query not returning what I'd expect. (7 posts)

  1. Jorenm
    Member
    Posted 3 years ago #

    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?

  2. esmi
    Forum Moderator
    Posted 3 years ago #

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

  3. Jorenm
    Member
    Posted 3 years ago #

    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.

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Where are you getting $id from?

  5. Jorenm
    Member
    Posted 3 years ago #

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

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    Try using $post->ID

  7. yaunus
    Member
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic