I have added category support for pages
in functions.php:
function add_categories_to_pages() {
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_categories_to_pages' );
I created the category 'saloane', I have pages with category 'saloane' added
in home.php:
$saloane_q = new WP_Query ( array('post_type' => 'page', 'category' => 'saloane' ));
if ($saloane_q->have_posts()) :
while ($saloane_q->have_posts()) : $saloane_q->the_post();
echo '<div class="f3">';
the_post_thumbnail('hr_medium');
echo '<h2>';
the_title();
echo '</h2>';
the_excerpt();
echo '</div>';
endwhile;
endif;
wp_reset_postdata();
?>
there should be only the pages with category 'saloane' shown, but instead all the pages are shown
I also tried:
$saloane_q = new WP_Query ( array('post_type' => 'page', 'category' => 11 ));
$saloane_q = new WP_Query ( array('post_type' => 'page', 'cat' => 11 ));
the same result.
with:
$saloane_q = new WP_Query ( array('post_type' => 'page', 'category_name' => 'saloane' ));
does not display anithyng
if I use it without post_type
like this:
$saloane_q = new WP_Query ( array('category' => 11 ));
$saloane_q = new WP_Query ( array('cat' => 11 ));
it displays the posts.