customization - Allow WP users to sort search result on a videos site

So I have a video site based on wordpress - The search page currently shows post in date order but I want the users to h

So I have a video site based on wordpress - The search page currently shows post in date order but I want the users to have an option to sort the results by different options for example sort by views, duration or even sort by date but they can have an option to select the sorting when they see the search result. here is the current code

<?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" title="">
            <img src="<?php echo $thumb; ?>" id="pic_<?=get_the_ID();?>" <? if (strpos($thumb,'xvideos')) { $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 -->

So I have a video site based on wordpress - The search page currently shows post in date order but I want the users to have an option to sort the results by different options for example sort by views, duration or even sort by date but they can have an option to select the sorting when they see the search result. here is the current code

<?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" title="">
            <img src="<?php echo $thumb; ?>" id="pic_<?=get_the_ID();?>" <? if (strpos($thumb,'xvideos')) { $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 -->
Share Improve this question asked Sep 1, 2019 at 9:34 Lost SouldLost Sould 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Solved by a dropdown -

    <h1 class="titlebar"><div id="sortby"> SORT BY:; 

Sort by Newest Oldest Most Viewed Relevance Duration

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745195956a4616088.html

相关推荐

  • customization - Allow WP users to sort search result on a videos site

    So I have a video site based on wordpress - The search page currently shows post in date order but I want the users to h

    6小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信