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
1 Answer
Reset to default 0Solved by a dropdown -
<h1 class="titlebar"><div id="sortby"> SORT BY:;
Sort by Newest Oldest Most Viewed Relevance Duration