I have tried everything I can to filter my posts by a custom field taxonomy.
What I have is a custom field with the name of "category" with the field type of "post object", and I am listing all of my pages on my site to choose from.
When I am on my blog post I select an item from the dropdown menu, and now what I want to do is to get the specific post that has the "category" post_title of the current page I am on.
For instance:
I am on the page "Construction", and in my blog post I have selected this page from the list of pages. Now I want to find the latest blog post with the "Category" post_title of "Construction".
My code:
$args = array(
'posts_per_page' => -1,
'offset' => 0,
'category' => '',
'orderby' => 'post_date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'post_title',
'terms' => $pageName
)
),
'post_type' => 'post',
'post_status' => 'publish',
'suppress_filters' => true );
$myposts = get_posts( $args );