Support Forum
Hi, i need to display only post from actual day
i´m trying this:
{% set args = { post_type: 'licitacion', orderby: 'fecha_apertura', order:'asc', tax_query: [ { taxonomy: 'tipo-de-obra', field: 'slug', terms: 'obras-viales', } ] , meta_query: [ { key: 'fecha_apertura', value: 'date("Y-m-d")', compare: '=', type:'DATE' } ]} %}
but don´t work. please, can help me with this? thanks
Hi,
If you want to query posts by date, please use the argument date_query
, read more in the documentation https://developer.wordpress.org/reference/classes/wp_query/#date-parameters
And refer to this topic https://wordpress.stackexchange.com/questions/52070/how-to-get-posts-published-between-a-date-and-today
Please note that: never use the PHP function in the View, you can run it via the proxy
{% set my_date = mb.date("Y-m-d") %}
then value: my_date,
Hi Long, i can make it work on VIEWS
{% set fecha = "now"|date('Y-m-d') %}
<h2>
Mano de Obra, Materiales y/o Equipos
</h2>
{% set args = { post_type: 'licitacion', posts_per_page: 180, orderby: 'fecha_apertura', order:'asc', tax_query: [ { taxonomy: 'tipo-de-obra', field: 'slug', terms: 'mano-de-obra-materiales-y-o-equipos', } ], meta_query: [ { key: 'fecha_apertura', value:fecha , compare: '=', type:'DATE' } ] } %}
{% set my_posts = mb.get_posts( args ) %}
{% if my_posts == null %}
Sin Licitaciones
{% else %}
{% for post in my_posts %}
<h3>{{ post.post_title }}</h3>
Tipo de Obra: {{ mb.get_the_term_list( post.ID, 'tipo-de-obra' ) }}<br>
Comitente: {{ post.comitente }}<br>
Lugar: {{ mb.get_the_term_list( post.ID, 'lugar' ) }}<br>
Fecha de apertura: {{ post.fecha_apertura | date( 'd-m-Y' ) }}<br>
Presupuesto oficial: {{ post.presupuesto_oficial }} ({{ post.presupuesto_oficial_moneda }})<br>
{% endfor %}
{% endif %}