Posts 2 Posts
[resolved] Grab connect meta information when displaying queried results (3 posts)

  1. djhsecondnature
    Posted 3 years ago #

    I'm showing of a custom post type (products) on a page - that I'm already querying to use targeted queries based on URL calls.

    if(isset($_GET)) $options = $_GET;
    $posts = new WP_Query( array(
    'post_type' => 'product',
    'showposts' => 30,
    'orderby' => $options['orderby'],
    'order' => $options['order'],
    'paged' => $paged,
    'developer' => $options['developer'],

    I want to do two things.

    1) Pull out connected meta information for each of the posts matching this query.

    2) Add another layer to this query and sort by a connected meta query (in this case "rating"). So in essence it would display all of the products in order of their rating.

    How would I go about achieving this?


  2. scribu
    Plugin Author

    Posted 3 years ago #

    It's a WP_Query instance: just use the normal 'orderby' => 'meta_value' parameter, described in the Codex.

    Same for retrieving meta: just use get_post_meta(), like for any other post.

    Also note that assigning a WP_Query instance to a variable called $posts might get confusing. Use $query or something like that.

  3. djhsecondnature
    Posted 3 years ago #

    I tried to query using: 'connected_type' => 'review_to_game', 'connected_items' => $post
    but it returned no results...

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic