• I am using this code in my sidebar:

    ‘<?php /* Creates a menu for pages beneath the level of the current page */
    if (is_page() and ($notfound != ‘1’)) {
    $current_page = $post->ID;
    while($current_page) {
    $page_query = $wpdb->get_row(“SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = ‘$current_page'”);
    $current_page = $page_query->post_parent;
    }
    $parent_id = $page_query->ID;
    $parent_title = $page_query->post_title;

    if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_status != ‘attachment'”)) { ?>

    <div class=”sb-pagemenu”><h2><?php echo $parent_title; ?> Subpages</h2>

      <?php wp_list_pages(‘sort_column=menu_order&title_li=&child_of=’. $parent_id); ?>

    </div>
    <?php } } ?>’

    Problem is the “Back to” part only shows the site plus the date of the post. How can I make it so the post Back to “Fruit” is linked to Fruit, which is a parent page?

    Also, if the parent has no subs, can it not show any <h2></h2> at all?

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter zonetrap

    (@zonetrap)

    OK! I got it working. But if the Parent has no children, the Parent doesn’t show up in the sidebar. Can anyone help me work around it?

    ‘<?php /* Creates a menu for pages beneath the level of the current page */
    if (is_page() and ($notfound != ‘1’)) {
    $current_page = $post->ID;
    while($current_page) {
    $page_query = $wpdb->get_row(“SELECT ID, post_title, post_status, post_parent FROM $wpdb->posts WHERE ID = ‘$current_page'”);
    $current_page = $page_query->post_parent;
    }
    $parent_id = $page_query->ID;
    $parent_title = $page_query->post_title;

    if ($wpdb->get_results(“SELECT * FROM $wpdb->posts WHERE post_parent = ‘$parent_id’ AND post_status != ‘attachment'”)) { ?>

    <div class=”sb-pagemenu”><h2><?php echo $parent_title; ?> Subpages</h2>

      <?php wp_list_pages(‘sort_column=menu_order&title_li=&child_of=’. $parent_id); ?>

    </div>
    <?php } } ?> ‘

    You might want to try the “Fold Page List” plugin. It’ll help a lot, if I’m understanding what you’re trying to do. (I might not, but I think I am.)

    Thread Starter zonetrap

    (@zonetrap)

    I tried the Fold Page List plugin, but it brings in all the pages. The code I had before only brings in the parents/children of the page parent I select.

    If there is a way to loop it where any parent that doesnt have a child dosnt show up in the sidebar or just displays the Parent, either will work. Right now it shows nothing on the sidebar when a Page with no children are selected. Just a blank area.

    https://www.pokersyndicate.com

    I tried the Fold Page List plugin, but it brings in all the pages. The code I had before only brings in the parents/children of the page parent I select.

    I’m not sure what you mean? The Fold Page List plugin will call in all pages of the sidebar, but fold out the parent of whatever child you’re on. The rest will just show the parent.

    So, if you had a bunch of bookmarks like:

    Animals
    – cows
    – chickens
    – pigs
    Vegetables
    – corn
    – peas

    If you were on “Pigs”, then the “Animals” list would be open, but Veggies wouldn’t.

    Unless you didn’t edit your stylesheet properly? The Fold Page List plugin sets the IDs and classes of the lists to match what page you’re on – then you just use your stylesheet to format it properly. So, if you left it as-is, without editing your stylesheet, then yeah – it’d list *everything*, because that’s the default.

    Thread Starter zonetrap

    (@zonetrap)

    “If you were on “Pigs”, then the “Animals” list would be open, but Veggies wouldn’t.”

    Ok, we are getting somewhere. If I were on Pigs, I would only want to see the Animals List, I dont want to see Veggies at all. If I click Veggies in the navigation header, Animals doesnt show at all, only Veggies.

    I see.

    Still, Fold Page List would do this – it’s just a matter of editing your stylesheet. FPL provides the classes and ID’s you need to make this happen.

    You’d just set the regular lists to “display:none;”, and set the “current page” class lists to “display:block;” in your stylesheet. Then whatever page you were on, the parent and child would be the only ones shown – the regular ones wouldn’t show up at all.

    Thread Starter zonetrap

    (@zonetrap)

    These are the two I would use correct?
    #navigation ul li a {
    border: #dedede 1px solid;
    border-bottom:none;
    padding: 2px 10px;
    display: block;
    font-weight:bold;
    background:#ededed;
    letter-spacing:0px;
    }
    #navigation ul li a:hover, #navigation ul li a:active, #navigation ul li.current_page_item a {
    background: #fff;
    color: #333;
    border: #ccc 1px solid;
    border-bottom:none;

    }
    Problem is, if I change the #navigation ul li a {
    dispaly to none, my navigation on the top of the site goes.

    No – you want to set the LI to display:none.

    So if your code outputs like this:

    <ul>
    <li class="current_page">Link 1</li>
     <ul> //subnav here
     <li>sublink</li>
     </ul>
    
    <li>Link 2</li>
     <ul> //subnav here
     <li>sublink</li>
     </ul>
    </ul>

    you’d set your stylesheet like so:

    #sidebar li {
    display:none;
    }

    #sidebar ul li.current_page {
    display:block;
    }

    That will set all the LI’s in your sidebar as “invisible” by default. But the *second* call sets the LIs with the class of “current_page” to visible.

    Sublinks will follow suit with the parent LI – so regular sublinks will also be gone, but the ones under “current_page” will appear.

    Thread Starter zonetrap

    (@zonetrap)

    Doodlebee,
    I gave this a shot, here is my style sheet:

    ‘#sidebar li
    {
    display:none;
    margin-bottom:5px;
    }

    #sidebar ul li.current_page
    {
    display:block;
    margin-bottom:5px;
    }’

    The “#sidebar ul li.current_page” section I had to add, it wasnt in there.

    As for the sidebar:
    ‘<div id=”sidebar”>

      <li class=”current_page”>
      <?php wswwpx_fold_page_list (‘sort_column=menu_order&’. $arglist); ?>

    </div>’

    Nothing ever came up when I did this. Hopefully Im doing it correctly. Thanks for your time and help on this.

    `<li class=”current_page”>

    <?php wswwpx_fold_page_list (‘sort_column=menu_order&’. $arglist); ?>`

    No, this is not how you do it.

    You activate the plugin, and then you need to go into your sidebar.php file and put in:

    <?php wswwpx_fold_page_list ('sort_column=menu_order&'. $arglist); ?>

    You might have to double-check that with the documentation – they tell you how to set up the sidebar using the plugin. I’m telling you from memory, so I may be forgetting something – so read the documentation on how to install and use.

    Once you get it installed and implemented on your site, then view your source code on the page, and check what classes are added to the current page. As I said, I’m telling you form memory – but I *believe* the ID’s (or classes – you have to check which it uses) are “current_page” and “current_page_parent”.

    After you’ve found that out, *Then* do your CSS styling to match, use the above example as a reference.

    Thread Starter zonetrap

    (@zonetrap)

    I have it up, but the current page really doesnt work. It shows all the pages. Hmmm, this is a toughie.

    li.sidebox li#pagenav li.page_item {
    display:none;
    }

    li.sidebox li#pagenav li.current_page_item {
    display:block;
    }

    Add that to the bottom of your stylesheet.

    Thread Starter zonetrap

    (@zonetrap)

    Added the code.

    It gives the parent, but no none of the children associated with it.

    Also, is there a way to forma tit so it looks like the sidebar box above and below it?

    It gives the parent, but no none of the children associated with it.

    I don’t see any children.

    Your sidebar is made up of parent li’s – none with a corresponding “child”. What is a child of what? And if that’s how it’s supposed to be, do you have it set up that way in your admin panel? It’s all based off of how you have it set up in your admin area. For example, if I have a category of “Socks”, and I want to add a subcategory of “red socks” to it, I create the category and make sure the proper” category parent” is selected. When I do that, I see the tree in my admin panel – it’ll look like so:

    1 Socks
    – 2 red socks

    Does yours look like that? because form what I see here, I’m *guessing* you’re setup in your admin panel looksl ike this:

    1 Socks
    2 red socks

    Let me know if I’m guessing wrong.

    Thread Starter zonetrap

    (@zonetrap)

    Mine looks like your example:

    1 Socks
    – 2 red socks

    That is why I find it weird, I know what you mean, it should unfold.

Viewing 15 replies - 1 through 15 (of 20 total)
  • The topic ‘Sidebar help’ is closed to new replies.