php - Wordpress custom post not showing featured -
php - Wordpress custom post not showing featured -
i have come across unusual problem when creating new wordpress theme. maybe because have been @ day need see if can spot error or see problem.
i trying display 'featured' posts per name of category , show 1 if has been checked in wp-admin section. yet defining within code shows latest post instead regardless of beingness featured or not.
<?php $args = array( 'post_type' => 'post', 'category_mame' => 'featured', 'posts_per_page' => 1 ); $the_query = new wp_query( $args ); ?> <?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <div class="push_2 grid_10 omega clearfix"> <article> <?php get_template_part( 'content', 'post' ); ?> </article> </div> <?php endwhile; endif; ?> </div>
please alter first this
'category_mame' => 'featured',
to
'category_name' => 'featured', // name not mame
here built-in status parameters of wordpress.
i don't know if thing searching can query post after status if add together post_status
$args
-array:
$args = array( 'post_type' => 'post', 'category_mame' => 'featured', 'posts_per_page' => 1, 'post_status' => 'publish', //or 'draft', 'trash', 'pending', ... (see link above) );
hope helps.
php wordpress
Comments
Post a Comment