Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$30
wp_nav_menu filter - custom entries stripping { } characters
I have run into an issue where I need a filter of some sort for the wp_nav_menu function. I am using a lot of custom entries for the nav menu for a very customized theme.
Basically, every category is a section of site and when you are in that section of site the menu changes. Each menu has a dynamic custom menu that performs a search based on the category.
The problem, adding a custom menu entry URL strips characters like {}. I have a variable I need to pass to the site which is working everywhere in the theme {$refid} but doesn't work in the wp_nav_menu because when I save the entry the curly brackets are stripped.
I assume a filter that changes the arguments for nav menu output would be sufficient but I don't know. But I need to be able to use the wp_nav_menu functionality and apply root relative links that can pass this variable through the menu.
/site/{$refid}/category/cat-name/?s=Relevant
This question has been answered.
Gary Smith | 10/06/11 at 7:58am
Edit
(2) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
10/06/11
8:10amJohn Cotton says:There is a filter called wp_nav_menu_objects which might be useful.
As you can see with the code below, you can change values or remove them all together.
function my_nav_menu_objects( $items, $args ) {
$items[0]->title = 'Change The Title';
$items[0]->url = 'http://newurl.com';
unset($items[3]);
return $items;
}
add_filter( 'wp_nav_menu_objects', 'my_nav_menu_objects', 0, 2 );
You can also add to the array so perhaps instead of having a menu item added through the dashboard you could add dynamically in this function using the various globals to determine what's about to be on screen and thus changing your input.Previous versions of this answer: 10/06/11 at 8:10am
-

Last edited:
10/06/11
8:14amJulio Potier says:Hello
i just tried this and works :
function gary_url( $url, $original_url )
{
return esc_html( $original_url );
}
add_filter( 'clean_url', 'gary_url', 10, 2 );
See you soon !
edit : put this code into your functions.php theme file.Previous versions of this answer: 10/06/11 at 8:13am | 10/06/11 at 8:14am
- 10/06/11 8:21am
Gary Smith says:It's simple, it works, carries the variable and no hassle. I have 1 question... what does the 10, 2 have to do with the filter?
- 10/06/11 8:23am
Julio Potier says:10 = priority (default is 10)
and i need to "catch" the $original_url variable, the 2nd one. So i have to pass "10" to gain acces to the 2nd var i need.
Then i added "2", the "apply_filter" from WP Core will pass me "2" vars, $url and $original_url to my filter.
So i can "play" with $original_url, escape it, and return it for you !
:) - 10/06/11 8:26am
Gary Smith says:Simple enough... it worked without a hassle and I've already fixed the site menus.
Thanks...
case closed for sure. - 10/06/11 8:28am
Julio Potier says:Glad to help !
My left eye is reading the WP Core while my right eye checks that I do not pee on the side ;)
haha
- 10/06/11 8:21am
This question has expired.
Gary Smith voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
