How to query extended Media type
-
Using the Pods Framework, I have extended the WordPress media content type and added a relationship field that links to one or more pods (
department
). An image can be associated with multipledepartments
.How do I query this extended media type to return media that contains a given department? I have tried:
$id = get_the_ID(); // the current department page $media_pods = pods('attachment', array( 'where' => "t.departments.meta_value LIKE '%$id%'", ));
and
$id = get_the_ID(); // the current department page $params = array( 'post_type' => 'attachment', 'posts_per_page' => 6, 'meta_query' => array( array( 'key' => 'departments', // Pods relationship field key 'value' => '"' . $id . '"', // Ensure exact match 'compare' => 'LIKE', ), ), ); $query = new WP_Query($params);
Neither returns any results. Note: the relationship field departments can contain more than one department.
Any tips are greatly appreciated!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- You must be logged in to reply to this topic.