categories - Wordpress get_pages based on page category -



categories - Wordpress get_pages based on page category -

i need get_pages or array of pages in wp based on 's category

i know wp doesn't come categories on pages i'm using in functions.php categories on pages.

add_action('admin_init', 'reg_tax'); function reg_tax() { register_taxonomy_for_object_type('category', 'page'); add_post_type_support('page', 'category'); }

now need utilize these categories in get_pages or wp_query in pages category.

<div class="productnav"> <ul> <?php $product_page_args = array( 'post_type' => 'page', 'order' => 'asc', 'orderby' => 'menu_order', 'child_of' => $post->id, 'category_name' => 'pillar-product' ); //$product_pages = get_pages($product_page_args); $product_pages = new wp_query($product_page_args); foreach ($product_pages $product_page){ ?> <li><?php echo $product_page->post_title; ?></li> <?php } ?> </ul> </div>

try this:

$product_page_args = array( 'post_type' => 'page', 'order' => 'asc', 'orderby' => 'menu_order', 'child_of' => $post->id, 'taxonomy' => 'category', 'field' => 'slug', 'term' => 'pillar-product' );

wordpress categories

Comments

Popular posts from this blog

c - Compilation of a code: unkown type name string -

java - Bypassing "final local variable defined in an enclosing type" -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -