• Hi folks,
    I have a problem with a query to display products on a certain page in a certain order.
    The query gets all the Child Pages from a given parent, finds certain custom fields within each Child Page and builds a nice display box based on the custom fields to display on the main products page.
    My problem is that the order of the resulting page is kind of random.
    I have tried to get the order to change but to no avail.
    The ideal scenario would be for the query to order the results using the Order value entered in the Page Attributes section when editing each Page.
    So, here is my (probably ridiculously clumsy) code for the function:

    <?php
    	$productsCF = get_post_meta(31, "products", true);
    	// gets the array of pages from the products category
    
    	$allProducts = explode(",", $productsCF);
    	// splits array into individual items
    
    	foreach ($allProducts as $product) {
    
    		$pieces = explode("|", $product);
    		// splits item names into handy chunks
    
    		$productlink = get_permalink($pieces[1]);
    		$productbannerblurb = get_post_meta($pieces[1], "productbannerblurb", true);
    		$productbannerlogo = get_post_meta($pieces[1], "productbannerlogo", true);
    		$productname = get_the_title($pieces[1]);
    		$class_slug = strtolower(get_the_title($pieces[1]));
    		$classy_slug = str_replace(" ","", $class_slug);
    		echo "<div class='prodbanner $classy_slug'>\n";
    		echo "<div class='prodblurb'>\n";
    		echo "<a href='$productlink'>";
    		echo "<img class='prodlogo' src='../../images/products/prodlogo-$classy_slug.png'>";
    		echo "</a>\n";
    		echo "<p>$productbannerblurb</p>\n";
    		echo "<a class='readmore' href='$productlink'>Read More...</a>\n";
    		echo "</div>\n";
    		echo "</div>\n";
    		query_posts("posts_per_page=-1&post_type=page&post_parent=$pieces[1]");
    
    		while (have_posts()) : the_post(); ?>			 
    
    		<?php endwhile; wp_reset_query();			
    
    			};
    	?>

    Can anyone help please?
    It seems like it should be a simple addition of an order_by parameter but for the life of me I can’t find where to reference that parameter.
    Thanks ??

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Query_posts – Order items by Page Attributes’ is closed to new replies.