[wp-hackers] Hijack "The Loop"?
codehooligans at codehooligans.com
Wed Apr 25 18:58:53 GMT 2007
No. You really don't want to do that. I can answer this because well
I know what you are working on.
For example on the custom search result page. If the your secret
'alum_search' parameter is present you are dropping into your custom
SQL query which hits you alumni table and searched for matching
records. the result of this query is a standard mysql array (see my
example below). If you don't have the secret 'alum_search parameter
then you default to using the WP Loop to display any Post/Page items.
You really can't hijack the loop since your table columns don't
really apply to WP functions like the_title(), the_content(), etc.
For your custom query you just need to make your own loop and display
the row information from your alumni contact table Something like the
following. This is straight from the PHP MySQL manual.
$query = "SELECT..."; // your custom quuery
$result = mysql_query($query);
while ($row = mysql_fetch_assoc($result))
On Apr 25, 2007, at 1:22 PM, Lorin Rivers wrote:
> Here's what I'm doing--I've got a custom table and some page
> template-fu to display data that is not "posts". WP is so post-centric
> that a lot of stuff doesn't work if the content is not in "the loop".
> Is it possible to make my custom PHP ACT like The Loop? And if so,
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
More information about the wp-hackers