Support

Account

Home Forums General Issues meta_key query with Post Object field Reply To: meta_key query with Post Object field

  • hi,

    i’m having the same problem. i can’t get my query to pull information that i’ve set up using a post object from a separate post type. i’m including the code below.

    any help would be greatly appreciated. 🙂

    <?php
    global $post;
    $args = array( 'post_type' => 'listing', 'posts_per_page' => -1, 'meta_query' => array( array( 'key' => 'sold_value', 'value' => 'Yes' ), array( 'key' => 'salesperson_name', 'value' => $salesperson = $_GET['salesperson'] ) ) );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) : setup_postdata($post);
    //Get the listing values
    include (ABSPATH . 'assets/dealer-functions/dealer-functions.php'); ?>
    <tr>
    <td class="vehicle-year center"><?php echo $man_year; ?></td>
    <td class="vehicle-title"><?php the_title(); ?></td>
    <td class="vehicle-stock right"><?php echo $car_stock; ?></td>
    <td class="vehicle-vin center"><?php echo $car_vin; ?></td>
    <td class="vehicle-acquired center"><?php echo $car_regdate; ?></td>
    <td class="vehicle-sold center"><?php echo $car_sale_date; ?></td>
    <td class="vehicle-list right"><?php if(empty($car_list_price)) { echo 'No Price'; } else { ?><?php if (is_numeric($car_list_price)) { echo number_format($car_list_price, 2, '.', get_option('wp_thousandseparator')); } else { echo $car_list_price; } ?><?php } ?></td>
    <td class="vehicle-base right"><?php if(empty($car_basecost)) { echo 'No Base'; } else { ?><?php if (is_numeric($car_basecost)) { echo number_format($car_basecost, 2, '.', get_option('wp_thousandseparator')); } else { echo $car_basecost; } ?><?php } ?></td>
    <td class="vehicle-sale right"><?php if(empty($car_sale_price)) { echo 'No Price'; } else { ?><?php if (is_numeric($car_sale_price)) { echo number_format($car_sale_price, 2, '.', get_option('wp_thousandseparator')); } else { echo $car_sale_price; } ?><?php } ?></td>
    <td class="vehicle-salesperson center"><?php if(!empty($get_salesperson)) { echo $car_salesperson; } else { echo 'None'; } ?></td>
    </tr>
    <?php endforeach; ?>
    </table>

    —-and—-

    array (
    'key' => 'field_5356425f36c39',
    'label' => 'Salesperson Name',
    'name' => 'salesperson_name',
    'type' => 'post_object',
    'post_type' => array (
    0 => 'salesrep',
    ),
    'taxonomy' => array (
    0 => 'all',
    ),
    'allow_null' => 1,
    'multiple' => 0,
    ),