Include 2 Category Names in query
-
Hi,
I’m trying to display custom posts which have 2 categories.
One category will have the same slug as the page the posts are on and the other category will have the same slug as the parent page of the current page.
I can’t find a way to display posts that have both those categories.
Here is my code:
<?php $post_data = get_post($post->post_parent); $parent_slug = $post_data->post_name; $page_slug = basename(get_permalink()); // the query $wpb_all_query = new WP_Query(array('post_type'=>'businesses', 'post_status'=>'publish', 'category_name'=>basename(get_permalink())+$parent_slug, 'meta_key'=>'featured', 'orderby'=>'meta_value','order'=>'DESC', 'posts_per_page'=>-1)); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Include 2 Category Names in query’ is closed to new replies.