Calling a Custom Field Value in the Wordpress Loop?

125 Views Asked by At

I am trying to call a custom field's metadata, and want to use it as a flag field for a Custom Post Type's Loop for a page. The field is 'tt_freemium'. The code I have below pulls everything and ignores the flag field. Uuuugh. What am I doing wrong ?

<?php $args = array( 'post_type' => 'membercontent', 'tt_freemium' => 'true', 'orderby' => 'post_date', 'order' => 'DESC', 'posts_per_page' => '200' );
    $ourposts = new WP_Query( $args );?>
1

There are 1 best solutions below

0
Miles Works On

The answer in case anyone wants to know is to add a meta_query and an array to fill the meta query. It works now. Sorry to bother anyone that read this. ;-) Have a nice day y'all.

<?php $args = array( 
'post_type' => 'membercontent',
'meta_query' => array(
  array(
       'key' => 'tt_freemium',
       'value'   => 'true',
  ),
'orderby' => 'post_date', 
'order' => 'DESC', 
'posts_per_page' => '200' );

$ourposts = new WP_Query( $args );?>