physaux Posted August 3, 2010 Share Posted August 3, 2010 Ok so, I'm in the process of struggling to create a WP plugin. I've narrowed down what I need to do to a few MYSQL commands. Basically, WP created a massively insane query for fetching posts to display on a certain page. WP would normally get this data now with the following MYSQL command: SELECT FOUND_ROWS() I am at the point in my code where I can replace this code, to manipulate the rows to my liking. (Through WP's "found_posts_query" filter hook; http://codex.wordpress.org/Plugin_API/Filter_Reference#Advanced_WordPress_Filters) What I want to do: -remove all rows CATEGORY = X except the first row that is CATEGORY = X -properly finish this operation with Select found_rows() (?i think?) *By the way I'm only very minutely experienced with MYSQL, so please bear with me. And so my question is... :confused:how the heck do i do this? Which mysql commands would I use? I'm totally lost. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/209725-need-help-fine-tuning-instead-of-select_found_rows-for-a-wp-plugin/ Share on other sites More sharing options...
trq Posted August 3, 2010 Share Posted August 3, 2010 I'm sorry, but your post makes little sense. What exactly is the question? Quote Link to comment https://forums.phpfreaks.com/topic/209725-need-help-fine-tuning-instead-of-select_found_rows-for-a-wp-plugin/#findComment-1094834 Share on other sites More sharing options...
physaux Posted August 3, 2010 Author Share Posted August 3, 2010 Ah, thank you for being blunt. I'll try and ask the question better this time. I'm writing a plugin for wordpress. Through the "found_posts_query" filter hook, I am able to add some custom MYSQL code inplace of WP's "SELECT FOUND_ROWS()" From the site: http://codex.wordpress.org/Plugin_API/Filter_Reference#Advanced_WordPress_Filters after the list of posts to display is queried from the database, WordPress selects rows in the query results. This filter allows you to do something other than SELECT FOUND_ROWS() at that step. That is the background information. I need help in formatting a MYSQL statement that will do the following objectives inplace of the original "SELECT FOUND_ROWS()": -return the same rows that the original SELECT FOUND_ROWS() statement would have, except... --I want to remove all rows but 1 that have a value of "7" for their category, and leave other rows that don't have "7" for category in their original order I have no idea how to create this MYSQL query.. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/209725-need-help-fine-tuning-instead-of-select_found_rows-for-a-wp-plugin/#findComment-1094849 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.