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 3497238
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:20:46+00:00 2026-05-18T12:20:46+00:00

I am working on a custom plugin in wordpress. I have a weird issue

  • 0

I am working on a custom plugin in wordpress. I have a weird issue with one sql.

SQL:

SELECT SQL_CALC_FOUND_ROWS wp_posts. *
FROM wp_posts
INNER JOIN wp_term_relationships 
ON ( wp_posts.ID = wp_term_relationships.object_id )
INNER JOIN wp_term_taxonomy 
ON ( wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id )
WHERE 1 =1
AND wp_term_taxonomy.taxonomy = 'category'
AND wp_term_taxonomy.term_id IN ('23')
AND (
wp_posts.post_author =1
)
AND wp_posts.post_type = 'post'
AND (
wp_posts.post_status = 'publish'
OR wp_posts.post_status = 'private'
)
GROUP BY wp_posts.ID
ORDER BY `wp_posts`.`as_stats_rating` DESC
LIMIT 0 , 30 

Its returning the correct data but its not sorting results according to as_stats_rating.
I am stumped. Does anyone know what I am doing wrong?

Edit 1 : Update

Here is the structure of wp_posts:
alt text


Sample result:

ID  as_stats_rating
1221   8
1222   10

All fields in sample results are :
ID post_author post_date post_date_gmt post_content post_title post_excerpt post_status comment_status ping_status post_password post_name to_ping pinged post_modified post_modified_gmt post_content_filtered post_parent guid menu_order post_type post_mime_type comment_count as_stats_numviews as_stats_numvotes as_stats_votestotal as_stats_rating


By the way, its not only about ‘order by wp_posts.as_stats_rating’, ‘order by wp_posts.as_stats_numviews’ have the same issue. (just to clear up, if you are wondering about as_stats_rating having varchar type)

  • 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-05-18T12:20:47+00:00Added an answer on May 18, 2026 at 12:20 pm

    Any chance that the as_stats_rating field is a string (char/text) datatype and not a numeric (float/int/decimal) datatype?

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

Sidebar

Related Questions

I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom
I'm working on the development of a C++ API which uses custom-designed plugins to
I often find linq being problematic when working with custom collection object. They are
In some instances, I prefer working with custom objects instead of strongly typed datasets
I'm working on a custom CMS for my own use and was thinking about
I'm working on a custom mark-release style memory allocator for the D programming language
As I'm working to add custom printing to my application, I've settled on using
I can't seem to get a custom action working. I might be doing this
I'm working on an RSS feed for a custom tasking system we use, and
I am working on localization for an app where custom patterns are used to

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.