• jensmolsson

    (@jensmolsson)


    Hello,

    Do anyone know if it is possible with using query_posts to priority/order by posts that have thumbnail?

    I have manage to sort out the once that have thumbnail but then I do not get the once that does not. So I still want posts that have thumbnail and the once that does not just that the once that have thumbnail should be priority.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    No – there’s no parameter for post_thumbnail.

    Thread Starter jensmolsson

    (@jensmolsson)

    Thanks for your answer Esmi.
    Is there a alternative way for doing this?

    Thanks!

    esmi

    (@esmi)

    You have to grab the post that you want and then run the results through some custom code that sorts the returned array of posts based on whether they have a post thumb or not.

    Thread Starter jensmolsson

    (@jensmolsson)

    Thanks Esmi. I will go for that 🙂

    Thread Starter jensmolsson

    (@jensmolsson)

    Here is the solution I used for this issue:

    //Post per page
    $post_per_page = 10;
    //Get all that have thumbnail
    query_posts($query_string."&posts_per_page=".$post_per_page."&meta_key=_thumbnail_id&orderby=meta_value&order=DESC");
    $posts = $wp_query->post_count;
    //Loop
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    
    	//Content
    
    endwhile; endif;
    
    //Get the rest
    if($posts<$post_per_page) {
    	$showPoster = $post_per_page-$posts;
    	query_posts($query_string."&posts_per_page=".$showPoster."&order=DESC");
    	//Loop
    	if ( have_posts() ) : while ( have_posts() ) : the_post();
    
    	//Content
    
    	endwhile; endif;
    
    }
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Priority posts that have thumbnail’ is closed to new replies.