Display pages child with certain custom field
-
Hey Guys!
Long time reader, first time poster…Im in a bit of a jam. I need a way to display the custom fields of pages child but only display the children whose custom field is a certain value.
I’m making an online store and the children of the page are the products (that will display on the store page). How can I just show i.e. the products that have a certain custom field value.
The code below shows every child, but i need to add a condition to it… its killing my brain! haha.
$children = get_pages('child_of=' . $post->ID. '&depth=-1' ); if (!empty($children)) { foreach($children as $child) { // Get the 2 meta values from the child page $shortdesc = get_post_meta($child->ID, 'short-description', true); $photo = get_post_meta($child->ID, 'product-photo', true); $price = get_post_meta($child->ID, 'price', true); $title = get_the_title($child->ID); // Display the meta values echo ' <ul> <div class="ProductContainer"> <h6> ' . $title . '</h6> <div id="shortdesc" class="floatleft">' . $photo . '</div> <p>' . $shortdesc . '</p> </div> <div id="submitbutton" class="floatright"> <form action="/cart" method="post" accept-charset="utf-8"> <input type="hidden" name="name" value=" ' . $title . '" /> <input type="hidden" name="price" value=" ' . $price . '" /> <input type="submit" name="Add to Cart" value="Add to Cart" class="submit" /> </form> </div><div id="ProductPrice">$' . $price . ' ' . $condition . ' + P&H</div> </ul>'; } } ?>
If anyone can assist I will shout from the heavens and flutes and confetti etc etc. ??
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Display pages child with certain custom field’ is closed to new replies.