[wp-hackers] Hijack "The Loop"?

Lorin Rivers lrivers at gmail.com
Wed Apr 25 19:20:41 GMT 2007


Paul is my hero, he got me to this point.

Take a look at my follow-up, though.

On 4/25/07, Paul Menard <codehooligans at codehooligans.com> wrote:
> 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))
> {
>      echo $row['firstname'];
>      echo $row['lastname'];
>      echo $row['address'];
>      echo $row['age'];
> }
> mysql_free_result($result);
>
> P-
>
>
> 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,
> > how?
> >
> > Thanks!
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list