Return page children for use in SQL query
Hi, I’m pretty new to all of this and am having a little trouble with a website I’ve recently designed http://www.luxxbox.com.au. On pages such as http://www.luxxbox.com.au/furniture I run the following code:
The point of this code is to select images labeled as hero whose titles match those of the pages which are children of the current page and display them in order based on the value in post_content. These images are then echoed as list items displayed in a carousel linking to their related page. The whole thing seems quite messy but the biggest problem is that using foreach to run the sql query over and over again is making for ridiculously long page generation times.
My one thought I’ve had is if there was some way to output the page titles (or IDs) from get_page as a single line seperated by “OR”, store this in a variable and then input it into the sql query then it would avoid the large number of queries I currently use.
For example get_pages outputs the page titles a b c then this gets saved as a variable $x=a OR b OR c; and then I use this variable in the query “SELECT * FROM wp_posts WHERE post_title=(‘” . $x . “‘”);.
Maybe there’s a really nice simple way to do this that I’ve missed because of my inexperience. Any help would be greatly appreciated!
- The topic ‘Return page children for use in SQL query’ is closed to new replies.