{"id":33965,"date":"2013-09-24T22:07:50","date_gmt":"2013-09-24T22:07:50","guid":{"rendered":"https:\/\/br.wordpress.org\/support\/topic\/exibir-post-por-data-inserida-no-custom-field\/"},"modified":"2016-08-06T01:23:48","modified_gmt":"2016-08-06T01:23:48","slug":"exibir-post-por-data-inserida-no-custom-field","status":"closed","type":"topic","link":"https:\/\/br.wordpress.org\/support\/topic\/exibir-post-por-data-inserida-no-custom-field\/","title":{"rendered":"exibir post por data inserida no custom field"},"content":{"rendered":"<p>Ola Pessoal,<br \/>\nCriei uma categoria chamada agenda que exibe post de festas e shows. \u00e9 uma esp\u00e9cie de agenda de shows personalizada.<br \/>\nGostaria de ordenar a exibi\u00e7\u00e3o dos post por data do show que adiciono atrav\u00e9s de um custom field. J\u00e1 li o codex, j\u00e1 tentei de tudo mas n\u00e3o consigo ordendar. experimentei todos os procedimentos do artigo: &#8220;https:\/\/br.forums.wordpress.org\/topic\/ordenar-posts-por-campos-personalizados&#8221; por\u00e9m nenhum deu certo. Ele n\u00e3o exibe em ordem de data.<\/p>\n<p>Algu\u00e9m pode me ajudar?<br \/>\nSegue meu c\u00f3digo:<\/p>\n<pre><code>&lt;?php if (have_posts()): while (have_posts()) : the_post();?&gt;\n&lt;?php $data = new WP_Query(&#039;orderby=meta_value&amp;order=ASC&amp;meta_key=data&amp;post_type=post&amp;post_per_page=7&#039;);?&gt;\n\n&lt;div id=&quot;agenda-geral&quot;&gt;\n&lt;div id=&quot;titulo-agenda-geral&quot;&gt;&lt;p&gt;&lt;?php the_title();?&gt;&lt;\/p&gt;&lt;\/div&gt;\n&lt;div class=&quot;texto-agenda-geral&quot;&gt;&lt;p&gt;&lt;a href=&quot;&lt;?php the_Permalink()?&gt;&quot;&gt;&lt;?php echo substr(get_the_excerpt(), 0, 503).&quot; [Ler Mais]&quot;; ?&gt;&lt;\/a&gt;&lt;p&gt;&lt;\/div&gt;\n&lt;div id=&quot;fotos-agenda-geral&quot;&gt;\n\t\t&lt;?php\n\t\t$key=&quot;img-agendag&quot;;\n\t\t$img = get_post_meta($post-&gt;ID,$key,true);\n\t\tif(isset($img) &amp;&amp; $img &gt;= &#039;1&#039;){ ?&gt;\n\t\t&lt;a href=&quot;&lt;?php the_Permalink()?&gt;&quot; title=&quot;&lt;?php the_title();?&gt;&quot; alt=&quot;&lt;?php the_title();?&gt;&quot;&gt;\n\t\t&lt;img src=&quot;&lt;?php $key=&quot;img-agendag&quot;;echo get_post_meta($post-&gt;ID,$key,true);?&gt;&quot;\n\t\ttitle=&quot;&lt;?php the_title();?&gt;&quot; alt=&quot;&lt;?php the_title();?&gt;&quot; width=&quot;169px&quot; height=&quot;131px&quot;&gt;&lt;\/a&gt;\n\t\t&lt;?php }else{}?&gt;\n&lt;\/div&gt;\n\n&lt;div class=&quot;cidade-geral&quot;&gt;&lt;p&gt;&lt;?php $key=&quot;cidade&quot;;echo get_post_meta($post-&gt;ID,$key,true);?&gt;&lt;\/p&gt;&lt;\/div&gt;\n&lt;div class=&quot;data-geral&quot;&gt;&lt;p&gt;&lt;?php if($data = get_post_meta($post-&gt;ID, &#039;data&#039;, $single = true)) {echo &quot;Data: $data&quot;;}?&gt;&lt;\/p&gt;&lt;\/div&gt;\n\n&lt;\/div&gt; &lt;!---agenda-geral---&gt;\n&lt;?php endwhile; else:?&gt;\n&lt;?php endif;?&gt;<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-33965","topic","type-topic","status-closed","hentry","topic-tag-custom-field","topic-tag-ordem","topic-tag-post"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/br.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/33965","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/br.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/br.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/br.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/33965\/revisions"}],"wp:attachment":[{"href":"https:\/\/br.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=33965"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}