Support » Fixing WordPress » list_cats & get_pages modded for multiple calls, questioning impact

  • rsramirez

    (@rsramirez)


    Hi all.

    I modified both list_cats & get_pages (called by wp_list_cats and wp_list_pages, respectively) so that they can be called more than one time successfully. I’m questioning the impact of my mod since I’m new to WordPress, and others out there with more intimate knowledge of the WordPress source code might have some insight to the impact of this modification.

    In the function list_cats, the line
    if (!count($category_posts)) {
    prevents 2nd and subsequent calls to wp_list_cats from retrieving the categories.

    Similarly, in the function get_pages, the line
    if (!isset($cache_pages) || empty($cache_pages)) {
    prevents 2nd and subsequent calls to wp_list_pages from retrieve the pages.

    As both lines of code obviously show, if the objects already contain categories or pages, the following lines should not execute. It is those following lines that obtain the categories or pages.

    While I’ve tested the modifications, I’m sure there’s a reason for putting those lines of code to prevent retrieval during subsequent calls – the question is why and what’s the impact of removing the code?

    -rsramirez

Viewing 2 replies - 1 through 2 (of 2 total)
  • pericat

    (@pericat)

    I was under the impression that those two lines guarded against creating links to empty pages and empty category archive pages, not that they held execution to one call.

    Thread Starter rsramirez

    (@rsramirez)

    Thanks! This is exactly the type of feedback I’m looking for. You might be right – I didn”t notice that since my pages and categories aren’t empty. If these lines guarded against empty cats/pages, I guess a side effect was restricting multiple calls, since when I removed the lines, I know can perform multiple calls.

    I’ll have to test if empty cats/pages show up; then this would be a drawback of my modification.

    Any other insight would be greatly appreciated.

    -rsramirez

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘list_cats & get_pages modded for multiple calls, questioning impact’ is closed to new replies.