允许WP用户在视频网站上对搜索结果进行排序

时间:2019-09-01 作者:Lost Sould

因此,我有一个基于wordpress的视频网站-搜索页面目前按日期顺序显示帖子,但我希望用户可以选择按不同选项对结果进行排序,例如按视图排序、持续时间排序,甚至按日期排序,但他们可以选择在看到搜索结果时进行排序。这是当前代码

<?php get_header(); ?>   <div id="main">


  <?php include(TEMPLATEPATH.\'/home_sidebar.php\') ?>




  <div id="content">
    <div class="mozaique"><h2 class="titlebar">Search result for <?php echo $_GET[\'s\'] ?></h2>
“rel=“bookmark”标题=”>
            <img src="<?php echo $thumb; ?>" id="pic_<?=get_the_ID();?>" <? if (strpos($thumb,\'xvideos.com\')) { $thumbbaseurl=explode(\'.\',$thumb); ?> onMouseOver="startThumbSlide(\'<?=get_the_ID();?>\', \'<?=$thumbbaseurl[3];?>\', \'<? echo $thumbbaseurl[0].".".$thumbbaseurl[1].".".$thumbbaseurl[2].".";?>\')"  onMouseOut="stopThumbSlide();" <?}?>alt="<?php the_title_attribute(); ?>" /> 

            </a>
          </div>
          <p><a href="<?php the_permalink() ?>"><?php echo tube_get_limited_string($post->post_title,36); ?></a></p>

          <p class="metadata">                <span class="bg">                  <span class="duration"><?php $duration = tube_getcustomfield(\'duration\',get_the_ID()); if(empty($duration)) $duration = \' \'; echo $duration; ?></span><?php  edit_post_link(\'Edit this entry\',\'\',\'.\'); ?> <?php if (is_admin_bar_showing()) { echo \'<a href="\'.get_delete_post_link().\'">Delete</a>\';}?>                                </span>              </p>
        </div>
      </div>



                        <?php endwhile; wp_reset_query(); ?>
                        <?php 
                        $next_page = get_next_posts_link(\'Previous\'); 
                        $prev_pages = get_previous_posts_link(\'Next\');
                        if(!empty($next_page) || !empty($prev_pages)) :
                        ?>
                        <!-- navigation -->
                        <div class="clear"></div>
                        <div class="navigation">
                            <?php if(!function_exists(\'wp_pagenavi\')) : ?>
                            <div class="alignleft"><?php echo $next_page; ?></div>
                            <div class="alignright"><?php echo $prev_pages; ?></div>
                            <?php else : wp_pagenavi(); endif; ?>
                        </div>
                        <!-- /navigation -->
                        <?php endif; ?>
                    <?php 
                    else :
                        ?><p class="nopost">Sorry, but you are looking for something that isn\'t here.</p><?php
                    endif;
                    ?>
    <?php if ( !function_exists(\'dynamic_sidebar\') || !dynamic_sidebar(\'Below Content\') ) : ?>
                    <?php endif ?>              </div> <!-- .mozaique -->
    </div>       

  </div> <!-- #content -->

1 个回复
最合适的回答,由SO网友:Lost Sould 整理而成

通过下拉列表解决-

    <h1 class="titlebar"><div id="sortby"> SORT BY:; 
按newestoldestmost viewedrelevatenceduration排序

相关推荐

Live search by custom tag

实时搜索:$the_query = new WP_Query( array( \'s\' => esc_attr( $_POST[\'keyword\'] ), \'post_type\' => \'custom_type\', \'sentence\' => \'true\' )); if( $the_query->have_posts() ) : while( $the_query->have_posts() ): $the_query->t