I am while using query_posts for "Page" item instead of "Publish". I wish to be capable of result in the "featured" page always on top, we're able to give a custom area known as "featured_product", whether it's eq "1" then display the publish as the initial one.
This is actually the fundamental code for that 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 are able to run a variety of query_posts()'s on the given page. This provides a couple options to exhibit featured pages then regular pages.
One of the ways, and exactly how I frequently organize content on my small WordPress sites, is to possess a 'featured' category. Featured posts or pages are designated this category, together with every other appropriate category. Then you definitely use that category title or ID inside your query_posts() or get_posts() query string.
//get featured posts (category_ID = 13) query_posts('cat=13&post_type=page'); //the loop goes here
One other way is by using meta_key and meta_value inside your query string.
query_posts('meta_key=featured_product&meta_value=1&post_type=page'); //the loop goes here
These two techniques think that once you query and display your featured pages, you'd query your standard pages by excluding the course designated to featured posts (13 within this example) or by utilizing meta_compare if custom fields are utilized
//get non-featured posts query_posts('cat=-13&post_type=page') //or query_posts('meta_key=featured_product&meta_compare=!=&meta_value=1'); //the loop goes here
If you wish to do all of it with one query and order by featured status, I speculate that you could order by meta_value.
//this might order by meta_value, i didn't test it. query_posts('post_type=page&orderby=meta_value_num&order=asc');
I suggest among the first approaches, because it allows custom styling from the featured items, and extremely will not have disadvantages. I've sites with 4 or 5 custom queries on each page.
Best Of Luck.