{"id":11652,"date":"2013-02-13T00:16:32","date_gmt":"2013-02-13T00:16:32","guid":{"rendered":"https:\/\/es.wordpress.org\/support\/topic\/category_and-y-orderby\/"},"modified":"2016-08-06T00:17:42","modified_gmt":"2016-08-06T00:17:42","slug":"category_and-y-orderby","status":"closed","type":"topic","link":"https:\/\/es.wordpress.org\/support\/topic\/category_and-y-orderby\/","title":{"rendered":"category__and y orderby"},"content":{"rendered":"<p>Hola, he mirado en el foro posibles soluciones, las he aplicado pero no me funcionan.<\/p>\n<p>Estoy haciendo una pagina, y necesito ordenar unos posts que pertenezcan a 2 categorias concretas, para ello, busqu\u00e9 por ah\u00ed, y tengo que usar el category__and. Hasta ah\u00ed perfecto.<\/p>\n<p>El problema es que si uso category__and los post no se ordenan del mas reciente al mas viejo, sino que se ordena por fecha de creaci\u00f3n, el primer post creado el primero y el \u00faltimo al final.<\/p>\n<p>C\u00d3DIGO USADO<br \/>\nNOTA: sobre el tema Infocus. Ellos dicen que pregunte aqu\u00ed:<br \/>\nhttp:\/\/mysitemyway.com\/support\/topic\/blog_list-order#post-110728<\/p>\n<p>CATEGORY__IN = FUNCIONA:<\/p>\n<pre><code>if( trim( $pagination ) == &#039;true&#039; ) {\n\t$paged = mysite_get_page_query();\n\t$blog_query-&gt;query(array(\n\t\t&#039;post__in&#039; =&gt; $post_in,\n\t\t&#039;category__in&#039; =&gt; $category_in,\n\t\t&#039;tag__in&#039; =&gt; $tag_in,\n\t\t&#039;post_type&#039; =&gt; &#039;post&#039;,\n\t\t&#039;posts_per_page&#039; =&gt; $showposts,\n\t\t&#039;paged&#039; =&gt; $paged,\n\t\t&#039;offset&#039; =&gt; $offset,\n\t\t&#039;ignore_sticky_posts&#039; =&gt; 1,\n&#039;orderby&#039; =&gt; &#039;date&#039;,\n&#039;order&#039; =&gt; &#039;DESC&#039;,\n\t));\n\n} else {\n\n\t$blog_query-&gt;query(array(\n\t\t&#039;post__in&#039; =&gt; $post_in,\n\t\t&#039;category__in&#039; =&gt; $category_in,\n\t\t&#039;tag__in&#039; =&gt; $tag_in,\n\t\t&#039;post_type&#039; =&gt; &#039;post&#039;,\n\t\t&#039;showposts&#039; =&gt; $showposts,\n\t\t&#039;nopaging&#039; =&gt; 0,\n\t\t&#039;offset&#039; =&gt; $offset,\n\t\t&#039;ignore_sticky_posts&#039; =&gt; 1,\n&#039;orderby&#039; =&gt; &#039;date&#039;,\n&#039;order&#039; =&gt; &#039;DESC&#039;,\n\t));\n}<\/code><\/pre>\n<p>CATEGORY__AND =  NO FUNCIONA<\/p>\n<pre><code>if( trim( $pagination ) == &#039;true&#039; ) {\n\t$paged = mysite_get_page_query();\n\t$blog_query-&gt;query(array(\n\t\t&#039;post__in&#039; =&gt; $post_in,\n\t\t&#039;category__and&#039; =&gt; $category_in,\n\t\t&#039;tag__in&#039; =&gt; $tag_in,\n\t\t&#039;post_type&#039; =&gt; &#039;post&#039;,\n\t\t&#039;posts_per_page&#039; =&gt; $showposts,\n\t\t&#039;paged&#039; =&gt; $paged,\n\t\t&#039;offset&#039; =&gt; $offset,\n\t\t&#039;ignore_sticky_posts&#039; =&gt; 1,\n&#039;orderby&#039; =&gt; &#039;date&#039;,\n&#039;order&#039; =&gt; &#039;DESC&#039;,\n\t));\n\n} else {\n\n\t$blog_query-&gt;query(array(\n\t\t&#039;post__in&#039; =&gt; $post_in,\n\t\t&#039;category__and&#039; =&gt; $category_in,\n\t\t&#039;tag__in&#039; =&gt; $tag_in,\n\t\t&#039;post_type&#039; =&gt; &#039;post&#039;,\n\t\t&#039;showposts&#039; =&gt; $showposts,\n\t\t&#039;nopaging&#039; =&gt; 0,\n\t\t&#039;offset&#039; =&gt; $offset,\n\t\t&#039;ignore_sticky_posts&#039; =&gt; 1,\n&#039;orderby&#039; =&gt; &#039;date&#039;,\n&#039;order&#039; =&gt; &#039;DESC&#039;,\n\t));\n}<\/code><\/pre>\n<p>Si uso category__in se ordenan bien, si uso category__and, da igual como lo ordene que el orden es el de la fecha de la creaci\u00f3n<\/p>\n","protected":false},"template":"","class_list":["post-11652","topic","type-topic","status-closed","hentry","topic-tag-orderby"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11652\/revisions"}],"wp:attachment":[{"href":"https:\/\/es.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}