I’m using the query_posts for “Page” item rather than “Post”. I want to have the ability to make the “featured” page always on the top, we could add a custom field called “featured_product”, if it’s eq “1” then display the post as the very first one.
Here is the basic code for the query. Someone help please!?
<?php query_posts(array('showposts' => 1000, 'post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'title', 'order' => 'ASC')); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
...
<?php endwhile; else: ?>
...
<?php endif; ?>
You can run any number of query_posts()’s on a given page. This gives you a couple alternatives to show featured pages then regular pages.
One way, and the way I often organize content on my WordPress sites, is to have a ‘featured’ category. Featured posts or pages are assigned this category, along with any other appropriate category. Then you use that category name or ID in your query_posts() or get_posts() query string.
Another way is to use meta_key and meta_value in your query string.
Both of these methods assume that after you query and display your featured pages, you would query your standard pages by excluding the category assigned to featured posts (13 in this example) or by using meta_compare if custom fields are used
If you want to do it all with one query and order by featured status, I speculate that you can order by meta_value.
I recommend one of the first approaches, as it will allow custom styling of the featured products, and really won’t have any downsides. I have sites with four or five custom queries on each page.
Good Luck.