Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Descriptions on WP nav menus causing strange behavior on forum page
Avatar
Bill Murray
Member
Free Members
sp_UserOfflineSmall Offline
Jan 9, 2012 - 12:16 am

Hopefully, I can communicate this odd question effectively.

I am using a Genesis theme, and have this little bit of code that adds descriptions to my WP custom menus.

/** Add description to secondary navigation */
add_filter( 'walker_nav_menu_start_el', 'add_description', 10, 4 );
function add_description( $item_output, $item, $depth, $args ) {

    $args = (array) $args;
       
    if ( $args['theme_location'] === 'primary' )  {
        return preg_replace( '/(<a.*?>[^<]*?)</', '$1' . "<span class=\"menu-description\">{$item->post_content}</span><", $item_output );
    }
    else {
        return $item_output;
    }

}

All works perfectly until I get to the SPF forum page.  On that page, it displays the menu descriptions, but below each description adds the word "Forums" below the menu description, colored as if it were a link, but it's not.  "Forums" happens to be the page title of my SPF forums page.

Without finding the cause, I created a page template that removed the WP primary navigation menus, and set that page template to the template for my SPF forum page, which seems to work fine.  I don't have to have the primary nav on the forums, since I can treat the forums like a landing page of sorts.

So my questions are:

1) is it ok to control the SPF forum page by setting a page template or will that break anything in SPF?

2) any idea why SPF would interact with my little bit of code?

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 9, 2012 - 3:46 am

I can answer #1 readily enough which is no - that's no problem at all. In fact we often advise users to do this who want to have a different look for their forum page.
As to #2 I probably need to be up longer with more coffee inside me.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Bill Murray
Member
Free Members
sp_UserOfflineSmall Offline
Jan 9, 2012 - 8:47 am

Great, thanks.  I had already implemented #1 when I made this post, and I actually prefer taking away the nav menu on the forum, since it introduces its own navigation options with breadcrumbs. 

#2 is strange.  It gets added after the span, but still inside the markup for each menu item which are list items.  It doesn't happen on any other WP page, just SPF, so it's at least SPF-related.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 9, 2012 - 11:25 am

Well - don't forget we may be massaging the page title behind the scenes prior to display - depending upon your forum SEO settings.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Bill Murray
Member
Free Members
sp_UserOfflineSmall Offline
Jan 9, 2012 - 12:32 pm

Ok.  But why would the page title impact the primary nav?  And every list element in the primary nav for that matter?

One thing I did not try but might find the time for is what SPF does when my primary nav is enabled but I do not add the description to it with that code.  My previous efforts did not use the Genesis primary nav menu, so the issue may not be with that code but the way 5.0 interacts with the Genesis primary nav menu.  I have had previous versions of 5.0 on Genesis where the primary nav menu was enabled, but the Genesis child theme was different and it might have had other stuff going on with the menus that I didn't take into account.

I'll let you know if my testing reveals anything of interest.

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 9, 2012 - 2:22 pm

Well I know nothing about Genesis so can't really comment.
My point was that a lot of menu type systems are based on the wp_list_pages() or wp_nav_menu() routines which pull in the page titles. Because we alter our page title based on the SEO settings these can pull in out massaged title instead of the page title. Actually they do because of a long-standing and annoying Wp bug.

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626