• webmasterobservatoriobioetica

    (@webmasterobservatoriobioetica)


    Hello, I have looked in the forum possible solutions, but I’ve applied work.

    I’m making a page, and I need to order some posts belonging to two specific categories, for this, I looked around, and I have to use the category__and. So much perfect.

    The problem is that if I use the post category__and not sorted from newest to oldest, it is sorted by date of creation, the first post created the first and last end.

    code used
    NOTE: Infocus on the subject. They say to ask here:
    http://mysitemyway.com/support/topic/blog_list-order#post-110728

    CATEGORY__IN = WORK:

    if( trim( $pagination ) == 'true' ) {
    	$paged = mysite_get_page_query();
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__in' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'posts_per_page' => $showposts,
    		'paged' => $paged,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    
    } else {
    
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__in' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'showposts' => $showposts,
    		'nopaging' => 0,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    }

    CATEGORY__AND = NOT WORK

    if( trim( $pagination ) == 'true' ) {
    	$paged = mysite_get_page_query();
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__and' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'posts_per_page' => $showposts,
    		'paged' => $paged,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    
    } else {
    
    	$blog_query->query(array(
    		'post__in' => $post_in,
    		'category__and' => $category_in,
    		'tag__in' => $tag_in,
    		'post_type' => 'post',
    		'showposts' => $showposts,
    		'nopaging' => 0,
    		'offset' => $offset,
    		'ignore_sticky_posts' => 1,
    'orderby' => 'date',
    'order' => 'DESC',
    	));
    }

    If I use category__in, all right, if I use category__and, not working 🙁

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter webmasterobservatoriobioetica

    (@webmasterobservatoriobioetica)

    in the forum, I’m see this, I think that I write correct, but.. don’t work, please, someone can helpme??

    At 2.3 this combination will return posts belong to both Category 1 AND 3, showing just two (2) posts, in descending order by the title:
    
    query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2, 'orderby' => 'title', 'order' => 'DESC' ) );
    Thread Starter webmasterobservatoriobioetica

    (@webmasterobservatoriobioetica)

    Please, The problem I have is meant? It is a big problem of WordPress or something I get wrong?

    I need order the post by date, the oldest in the end and the new at the beginning. But with the category__and no work the syntax “orderby”.

    So, what other syntax I set to order my posts?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘orderby and order with category__and’ is closed to new replies.