Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:07:11+00:00 2026-06-12T04:07:11+00:00

So I have managed to sort my posts with some basic settings. I want

  • 0

So I have managed to sort my posts with some basic settings. I want to change this from date-asc, date-dec, comments etc week, month, all time. I also was hoping to incorporate the following code which would sort the top voted posts only, instead of all posts

meta_key=votes_count&orderby=meta_value_num&order=DESC&posts_per_page=10

My working top rated page at the moment, which sorts my date-asc, title etc:

<?php
if( isset($_GET['o']) && $_GET['o'] != '')
      {
          $order = $_GET['o'];
          switch($order)
          {
            case 'date-asc': $orderby = 'order=ASC';
                        $msg = 'Date Ascending';
                          break;

            case 'date-desc': $orderby = 'order=DESC';
                        $msg = 'Date Descending(default)';
                          break;

            case 'date-mod': $orderby = 'orderby=modified';
                            $msg = 'Date Modified';
                           break;

            case 'title-asc': $orderby = 'orderby=title&order=ASC';
                            $msg = 'Title A-Z';
                            break;

            case 'title-desc': $orderby = 'orderby=title&order=DESC';
                            $msg = 'Title Z-A';
                            break;

            case 'comment': $orderby = 'orderby=comment_count';
                            $msg = 'Comment Count';
                            break;
          }
      }
      else
      {
          $orderby = 'order=DESC';
          $msg = 'Date Descending (default)';
      }
?>

<div id="content">

<div id="sorter-container">


<h2 id="sort-heading">Posts ordered by:<?php echo $msg; ?></h2>
    <select id="order-by">
        <option value="date-desc" <?php echo (!isset($order) || $order == '' || $order == 'date-desc')? 'selected="selected"':''; ?>>Date Desc. (default)</option>
        <option value="date-asc" <?php echo ($order == 'date-asc')? 'selected="selected"':''; ?>>Date Asc</option>
        <option value="date-mod" <?php echo ($order == 'date-mod')? 'selected="selected"':''; ?>>Date Modified</option>
        <option value="title-desc" <?php echo ($order == 'title-desc')? 'selected="selected"':''; ?>>Title Desc.</option>
        <option value="title-asc" <?php echo ($order == 'title-asc')? 'selected="selected"':''; ?>>Title Asc.</option>
        <option value="comment" <?php echo ($order == 'comment')? 'selected="selected"':''; ?>>Comments Count</option>
    </select>
</div>
    <script type="text/javascript">
            var orderby = jQuery('#order-by');
            var str;
            orderby.change(function(){
                str = jQuery(this).val();
                 window.location.href = "<?php echo home_url(); ?>/top-rated/?o="+str;
            });
  </script>

EDIT2:
Ok, so here is what I have, it no longer works, so I just continued and added week/month/alltime to where I think it should go (I know its not correct, but I wasnt sure how to limit the sort to just 7 days etc.

<?php
if( isset($_GET['o']) && $_GET['o'] != '')
      {
          $order = $_GET['o'];
          switch($order)
          {
            case 'week': $orderby = 'meta_key=votes_count&orderby=meta_value_num&order=DESC&WEEK&posts_per_page=10';
                        $msg = 'This Week (default)';
                          break;

            case 'month': $orderby = 'meta_key=votes_count&orderby=meta_value_num&order=DESC&MONTH&posts_per_page=10';
                            $msg = 'This Month';
                           break;

            case 'alltime': $orderby = 'meta_key=votes_count&orderby=meta_value_num&order=DESC&ALLTIME&posts_per_page=10';
                            $msg = 'All Time';
                            break;
      else
      {
          $orderby = 'order=DESC';
          $msg = 'This Week (default)';
      }
?>

<div id="content">

<div id="sorter-container">


<h2 id="sort-heading">Posts ordered by:<?php echo $msg; ?></h2>
    <select id="order-by">
        <option value="week" <?php echo (!isset($order) || $order == '' || $order == 'week')? 'selected="selected"':''; ?>>This Week (default)</option>
        <option value="month" <?php echo ($order == 'month')? 'selected="selected"':''; ?>>This Month</option>
        <option value="alltime" <?php echo ($order == 'alltime')? 'selected="selected"':''; ?>>All Time</option>
    </select>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:07:12+00:00Added an answer on June 12, 2026 at 4:07 am

    As described in the comments of the question your current code base does not make it possible to do what you want.

    wp-postratings Can do exactly like you want in the faq there is a question To Display Highest Rated Post Within A Given Period.
    Take a look there you should be able to figure this out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have managed to confuse myself whether I should return E_NOTIMPL or E_NOINTERFACE from
I have managed to bring the following output with this query SELECT DISTINCT IF(purchaseproduct_customerid=0,contactperson,vendorname)
I have managed to put this condition and rule below together to redirect a
I have managed to run hadoop examples grep, wordcount... however I am finding some
I'm looking for some help converting this from prototype to jQuery. I'm doing some
Essentially I want to have my blog grab wall photos, status updates, etc. from
I have an XML containing blog posts. Each post contains a date node. I
I have sort of a table with a radio-button column. I managed to make
http://jsfiddle.net/umbriel/CvhkM/1080/ In this fiddle I have managed to code so that when I hover
I have finally managed to verify some simple PGP signed message blocks. However, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.