• Hi guys!

    I’m in the process of developing a dynamic navigation system for a client website that uses the get_pages() function to build it hierarchically, based on parent and child Pages.

    Problem is, the get_pages() function is horribly big and inefficient, in that it grabs the content of the Pages, as well as the other attributes.

    1. is there an alternative to using the get_pages() function? And if not;
    2. is there a way of excluding the content part of the Page via a query of some sort, without hacking WordPress itself?

    Thanks, and speak soon…

Viewing 5 replies - 1 through 5 (of 5 total)
  • Perhaps you could try using get_all_page_ids then loop through the returned list and use get_page_link?

    Thread Starter WayneSmallman

    (@waynesmallman)

    Hi! It’s a worthy idea, but I need things like titles, names, IDs etc, which the above wouldn’t retrieve.

    But thanks anyway!

    Build a custom query that selects only the data you want…

    $wpdb->get_results("SELECT QUERY GOES HERE");

    Nearly every function you call is going to run a query to grab the data, so just forget about using numerous function calls and write your own query..

    Get all the pages you need, then use a series of arrays to sort and order the data.

    Looping over 3+ arrays to sort data is going to be far less intensive then adding extra queries.. When i say sort data, i simply mean break up all the posts(pages) up into array items and figure out how they relate in a hierarchal manner. I can’t give an example because i’ve not done it, but that’s simply how i’d approach it, were i aiming to do the same. ??

    Might even be able to use a fancy select statemnent to do it all in the query (depends on your ability to write sql queries).

    EDIT:: If you’re comfortable in writing basic queries, then you might be interested in the page i use for examples of queries (from very basic to very complex).
    java2s.com/Code/SQL/CatalogSQL.htm

    Also see the recommend below.. ??

    wpdb has some examples of the recommendation by t31os_

    Thread Starter WayneSmallman

    (@waynesmallman)

    Hi guys, and thanks for the responses!

    I was just in the middle of exploring the query_posts() function, but get_results() looks like a better candidate.

    Thanks again…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Alternative to get_pages() function?’ is closed to new replies.