I want on my homepage on my first page to be displayed only featured listings no matter how old they are
This is my homepage code:
<?php get_header(); ?>
<?php
if(get_option('aven_home') == "listing") { ?>
<?php include (TEMPLATEPATH . '/lib/listhome.php'); ?>
<?php } else { ?>
<div id="content">
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<div class="title">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
<div class="postmeta">
<span class="author">Posted by <?php the_author(); ?> </span> <span class="clock"> <?php the_time('M - j - Y'); ?></span> <span class="comm"><?php comments_popup_link('0 Comment', '1 Comment', '% Comments'); ?></span>
</div>
<div class="entry">
<?php
if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&h=150&w=200&zc=1" alt=""/></a>
<?php } else { ?>
<a href="<?php the_permalink() ?>"><img class="postimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>
<?php } ?>
<?php wpe_excerpt('wpe_excerptlength_index', ''); ?>
<div class="clear"></div>
</div>
</div>
<?php endwhile; ?>
<div class="clear"></div>
<?php getpagenavi(); ?>
<?php $wp_query = null; $wp_query = $temp;?>
</div>
<?php } ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
First, I recomend you to use pre_get_post hook for your purpose. If you are going to use only the new WP_Query in your theme, it has no sense that WordPress run a query before it gets your theme becuause it would be a extra work that will be discarded. Using pre_get_posts we can alter the main query to fit our purpose and get what we want without executing another query.
Thats said. Here an example code:
Put that code in functions.php and in your home.php template file you can run the loop as usual.
Custom post types has not support for built-in ‘sticky’ feature but you can create, for example, a tag or taxonomy term and filter by this tag. For example, if you custom post type support post_tags taxonomy you can created a term called ‘featured’ and attach each post you want to this tag and filter: