Menu label text reverting back to title text when using link_before/after in wp_list_pages All in One SEO Pack Troubleshooting Forum

The support forums have a new home! Please visit All in One SEO Pack's new residence at Semper Plugins to purchase a support plan.

Please consider registering
guest

Log In

Lost password?
Advanced Search:

— Forum Scope —



— Match —



— Forum Options —




Wildcard usage:
*  matches any number of characters    %  matches exactly one character

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
Menu label text reverting back to title text when using link_before/after in wp_list_pages
September 10, 2009
7:38 am
Cian McCoy
New Member
Forum Posts: 4
Member Since:
September 10, 2009
Offline

Hi, I'm using wordpress 2.8.4 and All in One SEO Pack version 1.6.5

I've found that when I use the link_before and link_after parameters for wp_list_pages any menu labels I've set revert back to the title text, so for example In the navigation menu I want it to have the first link text as "Home". But I want to have "Welcome to my site" for the title of that page.

This has been working completly fine, using the plugins Menu Label field.

However I need to insert an empty span within anchor text so I can use the css sliding doors technique, so basically I want it to output something like

<li><a href="#">Home<span></span></a></li>

When I use the link_after parameter for wp_list_pages the plugin stops working properly, the span appears but the menu label text becomes the same as the title text like

<li><a href="#">Welcome to my site<span></span></a></li>

is this a bug or am I doing something wrong?

heres the php I'm using for wp_list_pages

<?php wp_list_pages('title_li=&link_after=<span></span>'); ?>

Any help would be much appreciated

September 15, 2009
2:54 am
Cian McCoy
New Member
Forum Posts: 4
Member Since:
September 10, 2009
Offline

Now using AIOSEO version 1.6.6 and still having the same problem, anyone else having this problem?

Is this a common problem with the plugin or am I doing something else wrong?

Any kind of response would be much appreciated Smile

October 5, 2009
8:19 am
Paul
New Member
Forum Posts: 2
Member Since:
October 5, 2009
Offline

Hi,

I've been having the same problem and discovered that it's to do with a regular expression assuming you won't have any HTML in the links produced by wp_list_pages. Not sure if we've using the same version, but my AIOSEO is version 1.6.6.2 and if you change line 668 of the all_in_one_seo_pack.php file to:

$pattern = '/<li class="page_item page-item-(\d+)([^"]*)"><a href="([^"]+)" title="([^"]+)">(.+)<\/a><\/li>/i';

It should work.

Cheers,

Paul.

October 5, 2009
8:52 am
Paul
New Member
Forum Posts: 2
Member Since:
October 5, 2009
Offline

Sorry that's not the full fix you also need to edit the aioseop_filter_callback function around line 678 and change the 'if' statement to:

if (empty($menulabel)) $menulabel = $matches[5]; else $menulabel = str_replace($matches[4],$menulabel,$matches[5]);

Otherwise it'll strip out your span tags.

Cheers,

Paul.

October 7, 2009
7:01 am
Cian McCoy
New Member
Forum Posts: 4
Member Since:
September 10, 2009
Offline

Thanks for the response Paul, I'll try out your code when I get a chance.

It would be nice if you could do this sort of thing without having to hack the code.. ho hum

ATB

Cian

January 18, 2010
9:26 am
scottybowl
New Member
Forum Posts: 4
Member Since:
January 18, 2010
Offline

Just an update to this, the above regex needs to be modified slightly to work (missing some escapes), working code below:

$pattern = '/<li class="page_item page-item-(d+)([^"]*)"><a href="([^"]+)" title="([^"]+)">(.+)</a></li>/i';

Thank you Paul for your original solution, I was going slightly crazy!

January 18, 2010
9:29 am
scottybowl
New Member
Forum Posts: 4
Member Since:
January 18, 2010
Offline

Ahhhhh

The forum is stripping out the escapes so my code is also incorrect :(

Can you do anything moderators?

February 4, 2010
4:59 am
Cian McCoy
New Member
Forum Posts: 4
Member Since:
September 10, 2009
Offline

Just had this problem again with a different site, managed to fix it with Paul's code plus a few escapes!

Thanks for the help guys

March 26, 2010
8:27 pm
luckykind
New Member
Forum Posts: 1
Member Since:
March 26, 2010
Offline

Thanks for the fix Scotty…

Now can we get this fix implemented in an actual version so I don't have to fix it every time I upgrade?

September 6, 2010
10:58 am
angelopc
New Member
Forum Posts: 2
Member Since:
July 20, 2010
Offline
10

This fix just isn't working for me.

Forum Timezone: America/New_York

Most Users Ever Online: 205

Currently Online:
26 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

romiojuliat: 102

yaoming987: 50

jintuy: 50

miki1986: 33

newshow: 28

karen1234: 27

Member Stats:

Guest Posters: 0

Members: 6356

Moderators: 3

Admins: 4

Forum Stats:

Groups: 5

Forums: 23

Topics: 1546

Posts: 3450

Newest Members: carofern@cisco.com, pronto, jessie, pbaylies, ninaeast, freda

Moderators: davecashmore (2), aaron (5), tempadmin (0)

Administrators: WordPress Professional (442), hallsofmontezuma (202), onefinejay (10), stevemortiboy (4)