Title: [Plugin: WP Post Sorting] WordPress database error
Last modified: August 20, 2016

---

# [Plugin: WP Post Sorting] WordPress database error

 *  [clane_workforce](https://wordpress.org/support/users/clane_workforce/)
 * (@clane_workforce)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/)
 * I find this in my error_log:
 * [04-Oct-2012 10:41:45] WordPress database error You have an error in your SQL
   syntax; check the manual that corresponds to your MySQL server version for the
   right syntax to use near ” at line 1 for query SELECT * FROM wp_post_sorting 
   WHERE category = made by require(‘wp-blog-header.php’), wp, WP->main, WP->query_posts,
   WP_Query->query, WP_Query->get_posts, apply_filters_ref_array, call_user_func_array,
   post_sorting
 * Can you please fix? I love this plugin has been very helpful to organize my site.
   Thanks for your help.
 * [http://wordpress.org/extend/plugins/wp-post-sorting/](http://wordpress.org/extend/plugins/wp-post-sorting/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [jondaley](https://wordpress.org/support/users/jondaley/)
 * (@jondaley)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092231)
 * This happens for me, but only on pages that don’t exist. Since the plugin hasn’t
   been updated in a long time, I’m guessing the author has gone away. I’ll see 
   if I can find an easy fix for it.
 *  Thread Starter [clane_workforce](https://wordpress.org/support/users/clane_workforce/)
 * (@clane_workforce)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092232)
 * [@jondaley](https://wordpress.org/support/users/jondaley/) Thanks for your reply.
   I’ve communicated with the owner of the pluginand received the following reply:
 * > Unfortunately that plugin hasn’t been update in the last 2 years. What we’ll
   > try to do is try and update it in the next 30 days or so, because it’s not 
   > a big plugin and I realize there are still people still using it.
   > Thank you for reporting it,
   >  Cristian Antohe [http://www.reflectionmedia.ro](http://www.reflectionmedia.ro)
   > [http://www.cozmoslabs.com](http://www.cozmoslabs.com)
 * I hope you can find the issue. I’ve went through every line of code and thought
   it might be as simple as improper use of double and single quotes, but that is
   not the case. Take care:)
 *  [jondaley](https://wordpress.org/support/users/jondaley/)
 * (@jondaley)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092234)
 * I’m now looking into this, and adding myself (or others) a note here that when
   I said “pages” that don’t exist above, I actually meant it – not just “posts”
   that don’t exist…
 *  [jondaley](https://wordpress.org/support/users/jondaley/)
 * (@jondaley)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092235)
 * The bug is in wpps_hook_posts_orderby.php, though the code seems reasonable to
   me, at first glance:
 * `if(!is_category()) return;`
    followed by `get_query_var('cat');`
 * The get_query_var returns null.
 * I’ll take a look at the is_category function, since I don’t know why that is 
   returning true.
 *  [jondaley](https://wordpress.org/support/users/jondaley/)
 * (@jondaley)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092236)
 * Aha.
 * At least in my case, I am using the “custom structure” for permalinks, set to:/%
   category%/%postname%/
 * This causes *any* url that looks like /asldasldkjasdl to make is_category() return
   true.
 * I no longer think this is a bug in wp_post_sorting, but in the wordpress core,
   unless there is something I am doing wrong in my permalink settings, or there
   is an update to is_category() to make it actually check if it is a real category.
 * I fixed the bug by changing is_category() in wp-includes/query.php.
 * I don’t know why it always returns true if the category parameter given is empty.
   Though I am a little confused about having a member variable and a member function
   both named is_category – that seems like it is asking for trouble. I’m not sure
   why my “is_category” variable is set to true – must have gotten set somewhere
   previously…
 * I’ll try to forward this bug report to the WP core to see if someone can shed
   any light on this.
 *  [jondaley](https://wordpress.org/support/users/jondaley/)
 * (@jondaley)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092237)
 * No response today on the other bug, though there is a bug in the forums, so I’ll
   post it again tomorrow.
 * [http://wordpress.org/support/topic/heh-putting-a-percent-in-the-topic-title-causes-this-forum-to-break](http://wordpress.org/support/topic/heh-putting-a-percent-in-the-topic-title-causes-this-forum-to-break)
 * [http://wordpress.org/support/topic/permalink-%categorypostname-makes-is_category-return-true-for-404s](http://wordpress.org/support/topic/permalink-%categorypostname-makes-is_category-return-true-for-404s)
 * I have another fix, at least for when this bug appears in the post-sorting plugin,
   though the true fix is anyone who uses the is_category() function.
 * Add this line:
    `if(!$cat) return $orderby;`
 * in wpps_hook_posts_orderby.php after the existing line:
    `$cat = get_query_var('
   cat');`
 *  Thread Starter [clane_workforce](https://wordpress.org/support/users/clane_workforce/)
 * (@clane_workforce)
 * [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092238)
 * [@jondaley](https://wordpress.org/support/users/jondaley/) Thanks for the help.
   I’ll try this change and see if the SQL errors stop. I too am using a custom 
   permalink structure /%category%/%postname%/ same as you. Awesome:)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘[Plugin: WP Post Sorting] WordPress database error’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-post-sorting.svg)
 * [WP Post Sorting](https://wordpress.org/plugins/wp-post-sorting/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-post-sorting/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-post-sorting/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-post-sorting/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-post-sorting/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-post-sorting/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)

 * 7 replies
 * 2 participants
 * Last reply from: [clane_workforce](https://wordpress.org/support/users/clane_workforce/)
 * Last activity: [13 years, 4 months ago](https://wordpress.org/support/topic/plugin-wp-post-sorting-wordpress-database-error/#post-3092238)
 * Status: not resolved