我需要这个选择工作

时间:2018-09-09 11:49:02

标签: php jquery ajax wordpress

我需要这个选择在这里工作我有这段代码需要一个WordPress过滤器 我的帖子页面需要按日期过滤掉,我无法正常工作

<?php
if ($_GET['select'] == '2018') {
    $order = "&orderby=date&order=DESC";
    $s1 = ' selected="selected"';
}
if ($_GET['select'] == 'lastest') {
    $order = "&orderby=date&order=ASC";
    $s2 = ' selected="selected"';
}
if ($_GET['select'] == 'title') {
    $order = "&orderby=title&order=ASC";
    $s3 = ' selected="selected"';
}
if ($_GET['select'] == 'correct') {
    $order = "&orderby=modified";
    $s4 = ' selected="selected"';
}
?>
<form method="get" id="order">
    <select name="select" onchange='this.form.submit()' style="width:200px">
        <option value="2018"<?=$s1?>>2018</option>
        <option value="lastest"<?=$s2?>>по дате (сначала старые)</option>
        <option value="title"<?=$s3?>>по заголовку</option>
        <option value="correct"<?=$s4?>>по дате изменения</option>
    </select>
</form>

<?php
global $query_string; // параметры базового запроса
query_posts($query_string.'&'.$order); // базовый запрос + свои параметры
?>
<div class="news__page" id="container-01">
    <?php
    $args2 = array(
        'category_name' => 'news-company',
        'date_query' => array(
            array(
                'before' => array(
                    'year' => 2002,
                ),
                'inclusive' => true,
            ),
        ),
        'posts_per_page' => -1,
    );
    $loop = new WP_Query($args2 );
    while ($loop->have_posts()) {
        $loop->the_post();
        ?>
        <div class="news-item pinto">
            <div class="news-img">
                <?php if ( has_post_thumbnail() ) : ?>
                    <a  title="<?php the_title_attribute(); ?>"  href="<?php the_permalink(); ?>">
                        <?php  the_post_thumbnail(); ?>
                    </a>
                <?php endif; ?>
            </div>
            <div class="news-wrap">
                <a href="<?php the_permalink(); ?>" class="news-title"><?php the_title(); ?></a>
                <div class="news_text"><?php the_excerpt(); ?></div>
                <span class="news-data"><?php echo get_the_date() ?></span>
            </div>
        </div>
    <?php
    }
    ?>

我需要这个选择在这里工作我有这段代码需要一个WordPress过滤器 我的帖子页面需要按日期过滤掉,我无法正常工作

http://prntscr.com/ksbdia

0 个答案:

没有答案