视觉作曲家发布过去事件的网格自定义查询字符串

时间:2017-06-13 06:07:20

标签: wordpress post grid visual-composer

我想在主页中显示过去的事件。我使用可视化作曲家后网格自定义查询选项来比较当前日期并显示低于当前日期的帖子。

elif search_req == 'teacher':

    if request.method == 'POST':

        form = TeacherRegistrationForm(request.POST)

        if form.is_valid():

            user, teacher_profile = form.save(request)

            return render(request, 'accounts/home.html')
        else:
            args = {'form': form}
            return render(request, 'accounts/reg_form.html', args)

    else:
        form = TeacherRegistrationForm()
        args = {'form': form}                
        return render(request, 'accounts/reg_form.html', args)

我已使用此查询但未使用

1 个答案:

答案 0 :(得分:2)

从当前日期获取过去的事件

发布类型"事件"和元键名" date_short_order"

<?php
$today = date("Y/m/d h:i A");
$event_args=array(
    'type'                     => 'event',
    'post_status'              => 'publish',
    'posts_per_page'           => 3,
    'meta_key'                 => 'date_short_order', //event_date
    'orderby'                  => 'meta_value_num', //or 'meta_value_num' , 'meta_value'
    'meta_query' => array(
                        array('key' => 'date_short_order',
                              'value' => $today, 
                              'compare' => '=<',
                              'type' => 'DATE',
                        )
                    ),
    'order'                    => 'DESC',
);
$event_my_query = null;
$event_my_query = new WP_Query($event_args);

if( $event_my_query->have_posts() ) 
{
     while ($event_my_query->have_posts()) : $event_my_query->the_post(); 
        the_title();
      endwhile;
}
wp_reset_query($event_my_query);
?>
在URL编码时,

[]被%5B%5D替换。

&#39; [&#39; =%5B

&#39;]&#39; =%5D

post_type=event&posts_per_page=3&post_status=publish&meta_key=date_short_order&orderby=meta_value_num&order=DESC&meta_query[0][key]=date_short_order&meta_query[0][value]=$today&meta_query[0][compare]=<&meta_query[0][type]=DATE

visual composer post过去事件的网格自定义查询字符串:

post_type=event&posts_per_page=3&post_status=publish&meta_key=date_short_order&orderby=meta_value_num&order=DESC&meta_query%5B0%5D%5Bkey%5D=date_short_order&meta_query%5B0%5D%5Bvalue%5D=$today&meta_query%5B0%5D%5Bcompare%5D=<&meta_query%5B0%5D%5Btype%5D=DATE