admin管理员组文章数量:1289868
I turn to you since I tried by my means but I could not achieve it It turns out that I have the need to create an rss file to use it in external applications, I have a type of post (events) which contains a metakey with the date I need or the field I need to filter.
In a few words, what I need is a query that allows me to show the events of the current day, this by consulting the date field that contains the metakey. for now I have done the following:
date_default_timezone_set('America/Tegucigalpa');
$hoy = date('d');
require_once( 'wp-load.php' );
$events = new WP_Query(
array(
'post_type'=>'ajde_events',
'posts_per_page'=>10,
'post_status'=>'publish',
$meta_query = array(
array(
'key' => 'meta_key',
'value' => 'evcal_srow',
'compare' => '=',
'type' => $hoy,
)
)
)
);
With the above code I can show the last 10 events added, the metakey that saves the date is called evcal_srow
try the following:
while($events->have_posts()): $events->the_post();
$event_meta = get_post_custom($events->post->ID);
// featured image
$output= false;
if(has_post_thumbnail($events->post->ID)){
$output = get_the_post_thumbnail( $events->post->ID, 'medium', array( 'style' => 'float:right; margin:0 0 10px 10px;' ) );
}
$image = $output? $output:null;
// event date/times
$today= date('d', $event_meta['evcal_srow'][0]);
if ($hoy == $today){
/// eventos today
}
endwhile;
With the above it does not show the events, so I did a little research and I think the best way is to assign the metakey the current date
本文标签: Query to show post current day
版权声明:本文标题:Query to show post current day 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741485260a2381371.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论