Forums

[resolved] child_of argument set in wp_list_pages function returns nothing with eShop plugi (9 posts)

  1. MistressTalia
    Member
    Posted 5 months ago #

    I lost a day solving this problem.

    I am building a theme for a site that will use the eShop plugin and was trying to generate a sidebar menu on certain pages using this simple code in a function in a function in my functions.php:
    wp_list_pages("child_of=19");

    It returned nothing. I spent several hours trying to "solve" a possible syntax error, or so I thought. On the very same sidebar, I was using wp_list_bookmarks and it worked just fine and I couldn't see a difference in the syntax for passing arguments between my usage of the two functions. I read the codex repeatedly, couldn't figure out what I was doing wrong. I figured I was just not seeing something, so after several hours puzzling over semicolons, curly braces, quotes and doublequotes, trying to find my error, I eventually called it a day.

    The next day, I expected I'd look at my code and see an obvious syntax error I'd missed previously, as that ALWAYS happens to me. But nada. I tried it without the child_of argument and it returned a list! So next, I went to phpMyAdmin and verified that I had pages with that parent. Yes, I had the child_of ID right. I even wrote a SQL statement and verified that it returned the pages I wanted. Hmmm...

    Perplexed, I downlaoded my entire site and searched for: function wp_list_pages to see if I could figure it out. I hate doing this, as I don't know the codebase, and the functions all call other WP functions, and one gets into a loop of trying to understand things that I don't really want to understand; I'm trying to be a user of WP, not a developer of it.

    But I didn't have to dig through the code in that manner. I saw that there was a filter called wp_list_pages_excludes in the function and a search of the code for my site showed that eShop was using it. Which made a lot of sense since eShop puts "product" pages under "department" pages and whatnot. Obviously, I can't touch eShop's filter without breaking eShop.

    But I need to use the unfiltered function myself. I don't know if there's a better solution, but since I didn't want to understand the WP codebase well enough to roll my own function, I copied the wp_list_pages function into my functions.php file, renamed it to cw_list_pages (all my functions for this site are named "cw_something_or_other") and commented out the line where the output got filtered. And now cw_list_pages("child_of=19") works in my template.

    As noted, I am just putting this up so when someone else runs across the same problem and Googles, they'll find the answer, cause I sure didn't! This problem cost me a day of coding time and I hope I can save someone else the bother.

  2. elfin
    Member
    Posted 5 months ago #

    There was a simpler way - you can turn it off on the Settings - eShop page ...

  3. ittekudasai
    Member
    Posted 5 months ago #

    I am going through the same confusion. I swear child_of was working yesterday, and it's broken again today. I can put the code to be called before the get_header - and it works then - but that's not where I want the subpages listed!

    I don't want it in the sidebar, either. Hopefully I get it working again by some miracle.

  4. elfin
    Member
    Posted 5 months ago #

    it it was working one day and not the next could you have installed another plugin that may be affecting it?

  5. ittekudasai
    Member
    Posted 5 months ago #

    It was more devious (at least from my standpoint). I think I'm just working too long on this.

    I introduced an additional instance of the loop that was affecting the loop I expected the child_of to respond to.

    Once again, user error... it's what I get for messing around with templates.

    I'm a little concerned about plugins not playing nice together. They seem to be the most unstable part of WP, even though there are a great deal of them that are providing useful functionality.

  6. webmystery
    Member
    Posted 5 months ago #

    May I offer a suggestion -- the setting to "Hide sub pages from menu until top level page is visited" changed all of my child links in the pages widget. I didn't expect that, and since I had installed the 2.8 upgrade right before I installed eShop so I wasted an hour thinking it was a 2.8 problem. I only expected the plugin settigns to effect the pages that belong to that plugin. At the very least the option description should be worded differently so that we know it applies to ALL page links.

    I'm using the page lists plus plugin to disable links to selected pages or change the link text. It works great. The hide children feature would be a great addition to that plugin.

    That said, so far this looks like the best eCommerce plugin available for WP. Another highly rated one has some issues, and lots of people reporting the same issue in the forum and no response from the developer. Thanks for the good work

  7. elfin
    Member
    Posted 5 months ago #

    k, I'll add a warning in, thanks for bringing it to my attention.

  8. cantonax
    Member
    Posted 3 months ago #

    I think you must installed another plugin

  9. jparge
    Member
    Posted 2 weeks ago #

    Thanks so much for this thread, took away a good four hours of my time as well. I eventually did exactly what OP did, copying and renaming the function. LOL at the second post... I didn't even see that! XD

Reply

You must log in to post.

About this Topic