WordPress.org

Ready to get started?Download WordPress

Forums

Getting Sticky posts to work on cutom Query (1 post)

  1. nashakaratv
    Member
    Posted 2 months ago #

    Hi,

    I have created a custom query which displays News content in a specific area on the frontpage.

    I would like to be able to have the Sticky post feature work so that any "Sticky" posts remain at the top of the posts.

    How can I get this to work. This is the code I am currently using:

    $args = array(
    								'post_type' => 'post',
    								'category_name' => 'nashakaranews',
    								'posts_per_page' => 5,
    								//'post__in' => get_option('sticky_posts'),
    								'cat' => -270,
    							);
    							$query_news = new WP_Query( $args );
    							if ( $query_news->have_posts() ) {
    								echo '
    <ul>';
    								while ( $query_news->have_posts() ) {
    									$query_news->the_post();
    									echo '
    <li>';
    										?>
    										<a>" title="<?php the_title(); ?>">
    										<?php
    										the_post_thumbnail( 'event' );
    										?></a></li>
    </ul>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Reply

You must log in to post.

About this Topic