I’m trying to use custom taxonomy with pages. Basically a page has a “relevance” taxonomy, depicting who the page is relevant for. The pages are created in a hierarchy based on the departmental structure of the school district which the site is for. So say I’m on the alumni page, and I want to list all the child pages of educational services that are relevant, like how to get your transcripts.
I’ve tried the following two methods
<?php
$pages = get_pages( array( 'child_of' => '65','hierarchical' => 0, 'meta_key' => 'relevance', 'meta_value' => 'alumni' ) );
foreach ( $pages as $page ) {
echo $page->post_title;
}
?>
and
<?php wp_list_pages( array( 'child_of' => '65', 'meta_key' => 'relevance', 'meta_value' => 'alumni') ); ?>
both display the child pages of 65 without the meta_key & meta_value properties, but once I had them I get nothing. I’m super positive the values are correct.
I’ve also tried..
'relevance' => 'alumni',
like you would in a query, but that doesn’t work with these functions.
Any idea why this wouldn’t work? The get_pages function lists meta_key & meta_value under usage and denotes that you have to set hierarchical to 0 which I did.
Custom taxonomies are not meta values, but rather their own thing. I don’t think
wp_list_pages()
orget_pages()
can query based on a taxonomy, so I’d recommend using WP_Query instead: