• Resolved moabman1

    (@moabman1)


    Hello:

    I upgraded to 9.1 and now I’ve got a problem with the navigation related to my theme. I’m running mysql 5, which didn’t change between 8.* and 9.1. My customized theme is based on itheme-1-1. Here are the two problems:

    1. When users are logged out and I have all my plugins that worked under WP 8.* activated, none of the subpages show. The header shows, but the page simply stops loading without a php error.

    2. After playing with it, I discovered that removing some of the plugins allowed the sub pages to complete their loading, but instead of the submenu showing, it shows the main menu where the submenu should be.

    Now, when users are logged in, everything works fine. I attempting to test other navigation code in hopes I can remove the existing code. However, I haven’t found anything in the codex (I’ve tried the suggestions on the Pages/Nav Codex for example) that returns the parents and children of the parent page correctly.

    You can see an example here: http://www.ewillys.com/?page_id=3339. See how the submenu looks the same as the parent menu.

    Here’s the code for the top level menu and sub menu creation:
    ========= From Itheme 1-1 which go the code from K2 theme

    <div id="nav">

      <li class="page_item <?php if ( is_home() ) { ?>current_page_item<?php } ?>">/" title="Home">Home
      <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=');?>

    </div><!-- /nav -->

    //// IT'S RIGHT HERE WHERE THE CODE BREAKS WHEN ALL PLUGINS ARE INSTALLED///

    <?php /* Menu for subpages of current page (thanks to K2 theme for this code) */
    global $notfound;
    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'")) {
    if ($wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_parent = '$parent_id' AND post_type != 'attachment'")) {
    ?>

    <div id="subnav">

      <?php wp_list_pages('sort_column=menu_order&depth=1&title_li=&child_of='. $parent_id); ?>

    </div><!-- /sub nav -->
    <?php } } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter moabman1

    (@moabman1)

    I tested a different piece of code. This PHP piece correctly returns the right menu when users are logged in:

    <?php wp_list_pages('child_of=' . wpe_highest_ancestor()); ?>

    with this inserted in the functions.php file

    function wpe_highest_ancestor(){
    global $post;
    $page_ancestors = end($post->ancestors);
    if(!empty($page_ancestors)){
    $child_of = $page_ancestors;
    }else{
    $child_of = $post->ID;
    }
    return $child_of;
    }

    However, when users are logged out, instead of a repeat of the top menu in the submenu space (discussed above), I get all the submenus for each parent menu item AND I get an error message that says: Warning end() [function end]: Passed variable is not an array or object in the functions.php on line 3634

    Thread Starter moabman1

    (@moabman1)

    I finally created a box that appears on all subpages which states that there was a problem with the wordpress upgrade and that all uses who wish to see the subpage options should register.

    It’s non optimal, but I’m not sure what else to do at this point.

    Thread Starter moabman1

    (@moabman1)

    Also, the example noted in post 1 has been corrected based on the work-around mentioned in post 3.

    The site is http://www.ewillys.com

    My feeling at this point is that there is some conflict that is keeping non registered users from accessing the code necessary (maybe even function.php?) to make the submenus, and perhaps the sidebar, operate correctly.

    I think I will try manually installing wordpress 9.1 to see if there was a problem installing the upgrade correctly. That might explain my unusual glitches.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Upgraded to 9.1 and my navigation is misbehaving’ is closed to new replies.