• Resolved mzimmers

    (@mzimmers)


    I’ve been trying to get wp_list_pages() to work the way I want it to, and it occurred to me that part of my problem may be a faulty assumption: that a Sub-Page is the same as a Page. Is this true?

    If this is true, then why does it say here:

    wp_list_pages

    That the code in the second box won’t work when on a child Page?

    Thanks.

Viewing 11 replies - 16 through 26 (of 26 total)
  • 1. Yep. It’s a general, internal function several others (such as wp_list_pages()) act as wrappers to.

    2. Yup. It will display the parent (if any), current and child pages (if any), relative to the current Page. I’d have to locate my thinking cap for a deep diving version. Not sure where it is right now…

    Seriously, if you want to find a parent 2 (or more) levels up, that data doesn’t exist with the current $post object. So one has to start querying the database to get at it.

    2. Yelp. Leftover stuff from *my* testing while tracking down the bug. I’ve edited it out.

    Thread Starter mzimmers

    (@mzimmers)

    OK, well, I can get working on a three-level solution, but before I do, there’s still something not quite right here. When I navigate to a sub-Page, its title doesn’t get pulled in by the wp_get_pages. Similarly, when I navigate to a sub-sub-Page, neither its title, nor its parent’s title, gets pulled in.

    The behavior is consistent now…it’s just not quite correct. Any ideas?

    Which code are you using?

    Using the last stuff I pasted up, on my test server I visit a top level parent page and see:

    # THISPAGE 1207
    -Visuals
    # CHILDREN
    -Wallpapers
    -Rachael Leigh Cook Image Project (!)

    Clicking through to Wallpapers (where I placed a child Page just for you), I get:

    # PARENT 1207
    -Visuals
    # THISPAGE 1208
    -Wallpapers
    # CHILDREN
    -Custom Fields (Don’t ask!)

    Then once again, hitting Custom Fields:

    # PARENT 1208
    -Wallpapers
    # THISPAGE 1264
    -Custom Fields

    That looks right to me (note: using 2.3.1).

    Thread Starter mzimmers

    (@mzimmers)

    Well, I must be doing something wrong, then — the code in my l_sidebar.php file is identical to what you posted (after your edit). But, if I were using your examples, clicking on Wallpapers would not have the “-Wallpapers” line that you get. And, clicking on Custom Fields would not have either the “-Wallpapers” or the “-Custom Fields” lines.

    Could it have something to do with my formatting? Seems unlikely, I know, but…

    it’s at https://www.scopedin.com/wordpress if you want to see for yourself. Go to “Reviews” then to “Firearm Reviews” then to “Ruger Super Redhawk Alaskan.” You’ll see both mistakes in that sequence.

    Are you *absolutely* sure your template is being updated on the server? Because looking at your site, I see exactly what happens when ‘hierarchical=0’ is not passed as an argument. And that is the only real difference between my code and yours.

    Thread Starter mzimmers

    (@mzimmers)

    Are you asking whether I’m sure that I’m uploading my edited l_sidebar.php file?

    Because if you’re not asking that, I don’t understand the question.

    I’m asking when uploading that template, are you sure it’s being overwritten on the server. FTP can be twitchy about that at times.

    Thread Starter mzimmers

    (@mzimmers)

    Sigh. Deus Ex Machina strikes again.

    I downloaded the server copy, compared it with my local version, and they were identical.

    So…I cut out all of the code I’d put in, pasted in yours, and…voila.

    I had something subtle out of kilter in my version. No idea what it was, and, as much as I’d enjoy the academic exercise of trying to find out what it was…I think it’s time to move on.

    I’ll mark this resolved. Since I only want one level above and below the current page, this doesn’t need any enhancement, so I’ll mark this resolved and go on to other matters like indentation and background colors.

    Thanks for all of your help on this, Kafka.

    I have written a plugin that depends on hierarchical=1 along with include= … specifically, I create a page-list that shows an indented “breadcrumb-style” list of pages from top-level down to your current location, along with all the current page’s “brothers” and “uncles” etc. up to the main level.

    The patch #5373 breaks this functionality, because my “&hierarchical=1” gets overridden, and the page structure collapses.

    In other words, $hierarchical needs to default to 1 if &include= is not specified, and default to 0 if &include= is specified. But now an explicit specification gets discarded.

    One way to solve this is change line 1146 to be:

    if ($hierarchical == 1) $hierarchical = false;

    and line 1126, make the default “2” (so an explicit “1” won’t override):

    ‘sort_column’ => ‘post_title’, ‘hierarchical’ => 2,

    Perhaps there’s a more elegant way of making a “dependent default” but this makes all cases work.

    — \\/illiam

    I’m trying to create a sub page. I don’t even know where to start. help!!

    I’d start with reading the documentation. It always helps me… Pages
    especially: this section

Viewing 11 replies - 16 through 26 (of 26 total)
  • The topic ‘is a Sub-Page just a Page?’ is closed to new replies.