Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

[SOLVED] Tiered menus first level duplicated at 'Not found' page


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Nov 15, 2012, 08:49 AM
Sprutt
 
12 posts · Feb 2010
Hello,

After some extensive Googling I've managed to put together a multi-tiered menu using the wp_list_pages function. It works great everywhere except on the "Not found" page. On that page the code somehow gets it wrong and outputs the first level elements as a subnav/second row, which results in a duplication of the main menu. See code below.

Does anyone have a clue to why this is? And how do I resolve it?

I thought that maybe a custom 404 template would fix it, but when I put a 404.php in my Atahualpa folder it doesn't get used as I read somewhere it would...

The code that goes in header.php looks like this:

PHP Code:
<ul id="nav">  
    <?php 
        $exclude_pages 
= array('nyheter');
        
$excl_str = array();
        foreach( 
$exclude_pages as $title ) {
        
$page get_page_by_title$title );
        
$excl_str[] = $page->ID; }
        
$excl implode(','$excl_str);
        
        
wp_list_pages('title_li=&depth=1&exclude='.$excl.''); 
    
?>  
</ul>  

<?php 
    $parent_id 
$post->post_parent;
    
$parent get_post($parent_id);
    
    if(
$post->post_parent){
        if(
$parent->post_parent){
            
$child wp_list_pages("depth=1&title_li&child_of=".$parent->post_parent."&echo=0&exclude=".$excl."");
            
$child2 wp_list_pages("depth=1&title_li&child_of=".$parent->ID."&echo=0&exclude=".$excl."");
        } else {
            
$child wp_list_pages("depth=1&title_li&child_of=".$parent_id."&echo=0&exclude=".$excl."");
            
$child2 wp_list_pages("depth=1&title_li&child_of=".$post->ID."&echo=0&exclude=".$excl."");
        }
    } else {
        
$child wp_list_pages("depth=1&title_li&child_of=".$post->ID."&echo=0&exclude=".$excl."");
    }
    
    if(
$child){
        echo 
'<ul id="subnav-level-1" class="subnav">'."".$child."".'</ul>';
    }
    if(
$child2){
        echo 
'<ul id="subnav-level-2" class="subnav">'."".$child2."".'</ul>';
    }
?>
Thanks in advance for any help!

Last edited by Sprutt; Nov 15, 2012 at 09:04 AM.
  #2  
Old Nov 15, 2012, 10:13 AM
juggledad's Avatar
juggledad
 
22,162 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
I would have to see the site to understand what you are doing.
Also it would be helpful to know what version you are running....
__________________
Give a person a solution, you fix one issue, teach a person how to solve their problem you enable them forever.
Juggledad | Forum Moderator/Support
  #3  
Old Nov 16, 2012, 09:19 AM
Sprutt
 
12 posts · Feb 2010
Hey Juggledad! Thanks for helping out.

Unfortunately I can't show you the actual site since it is not live yet, but in the image below you can see what I'm doing. Does that clarify my problem?

  #4  
Old Nov 16, 2012, 01:53 PM
juggledad's Avatar
juggledad
 
22,162 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
I would add some 'echo' statements in your code so ou can see what is executing, something like
HTML Code:
ehco 'I am in the first if<br>';
etc, the you might see what is going on.
__________________
Give a person a solution, you fix one issue, teach a person how to solve their problem you enable them forever.
Juggledad | Forum Moderator/Support
  #5  
Old Nov 19, 2012, 06:51 AM
Sprutt
 
12 posts · Feb 2010
Thanks for your help Juggledad!

I did some echoing and found out that all the variables for post id and post parent id were not set when you were at the 'Not found' page. So I just made my else into an else if with an isset check in, like below if anyone is interested.

PHP Code:
else if(isset($parent_id)) 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Child sub menus overlap parent menus on H-Page menu bar cainj99 Page & Category Menu Bars 0 Jan 6, 2012 01:12 PM
"Don't link first level parent items in Page Menu Bar" with WP menus? lehacarpenter Page & Category Menu Bars 11 Nov 19, 2011 08:16 AM
Two level menus - Page Dependent jaxon Page & Category Menu Bars 3 Apr 27, 2011 01:11 PM
Menu 1 Settings not Displaying on Top Level Menu Item using WP3 Menus fantasychess Page & Category Menu Bars 2 Jan 7, 2011 02:25 PM
Duplicated meta fields when using static page as homepage - v. 3.4.2 pgc Atahualpa 3 Wordpress theme 0 Aug 7, 2009 08:22 AM


All times are GMT -6. The time now is 03:44 PM.


Powered by vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.