How do I display page children by category only
-
Hi there,
I’m building a small e-commerce page to add onto a client’s site, I’d like to be able to list products by category. Each product is a new ‘page’ and I’m able to list them on a landing page like so:
<?php $child_pages = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = ".$post->ID." AND post_type = 'page' ORDER BY menu_order", 'OBJECT'); ?> <?php if ( $child_pages ) : foreach ( $child_pages as $pageChild ) : setup_postdata( $pageChild ); ?>
However, as each product has a category attached (ie: Book, eBook, Audio, etc…) am I able to list them by category too? eg: So only those with the category ‘Book’ are displayed.
- The topic ‘How do I display page children by category only’ is closed to new replies.