Jump to content

Need help "fine tuning" instead of select_found_rows(). For a WP Plugin!?


physaux

Recommended Posts

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!

Link to comment
Share on other sites

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.. :confused::shrug:

Thanks!

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.