Are you talking about passing parameters in the link? For example if you link is this:
http://adomain.com/apage
and you wanted to pass the parameter ‘mydata’ with the value of ‘thisdata’, you would code:
http://adomain.com/apage/?mydata=thisdata
and, then in the php that process the url, use this to get the data:
$myvalue = $_GET('mydata');
actually what I want to pass is http://adomain.com/apage/?HotelID=<?php echo SESSION[‘HotelID’]; ?>
I need to see the code around the link, maybe 5 to 10 lines before and after, or put the entire php file in a pastebin and post the link here.
Thanks vtxyzzy for your reply.
I want to give this link in custom menus.
Actually we are using 2 databases in wordpress so i have set up whole site on sessions and we want to display that session variable as ?HotelID=session variable and this links are in custom menu that why I am not able to write php in there.
I think you can do what you want using a ‘walker’ in the wp_nav_menu. Here is a tutorial on how it works.
hey!
Can you help me how can I write walker class for adding php writing ability in URL?
I am not able to understand how can I add that facility.
Thnaks.
Arpita
The tutorial explains it very well.
Hey vtxyzzy,
You were right that tutorial is really good, I have added session id in url and now I just have to do styling.
Thanks for your help, I really appreciate it.
Thnaks once again.
Arpita
Hi vtxyzzy,
one last question, I have written walker class and it is doing what it should be doing, but how it can be directly applied to custom menus?
Thanks in advance.
Arpita
I really can’t explain it better than in the tutorial.
You set up your call to wp_nav_menu like this:
wp_nav_menu( array(
'container' =>false,
'menu_class' => 'nav',
'echo' => true,
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'depth' => 0,
'walker' => new description_walker())
);
Then, the walker is called once for each menu item. You manipulate the item in the walker and return whatever output you want for that item.
anyways thanks for your help.
I found the way around.
km
(@kmaisch)
Hi arpitap,
Just wondering if you could share your custom walker? I have been trying to figure out how to add a “?clicked=1” to all the URL’s in a custom wp_nav_menu – so that I can then use a Java script on the linked pages to determine if the user arrived on that page by using the menu…
I just can’t figure out how to get the walker working…
Cheers,
Kim
Hi everyone !
I’m trapped as km seems to be with the walker thing.
I’e tried sad tricks as past ?lang=<?php echo $lang;?> at the end of the link so it would be correctly prompted by the back office input box, but it daoesn’t work (at all). It shows up OK on rollover but doesn’t get “run” by the php code and satys as it shows ,
?lang=<?php echo $lang;?>
I must be so noob I can even get it right, but I can’t see how I could get a dynamic variable to stick inside the custom link URL .
As arpitap needed to, I have to add a ?lang=<?php echo .$Lang; ?> – or something like that – afterwards. And I can’t get it to work, I’m goin nuts any help would be much appreciated.
Thanks