Don’t hardcode the links. Use something like:
<?php $my_link = home_url( '/' ) . get_permalink( $id );>
<a href="<?php echo $my_link;?>"></a>
where $id is the id of your chosen page.
is there a easy way to manage footer links like policy and linking them.?
Yes – use the kind of approach I outlined above.
I have a question. what if my permalink is post name instead of id? i tried this
<?php $my_link = home_url( '/' ) . get_permalink(51); ?>
<?php //var_dump($my_link);exit; ?>
<a href="<?php echo $my_link;?>"> <p>Privacy policy</p></a>
and the url i got was
The requested URL /abc/http://localhost:8888/abc/ was not found on this server.
obviously there r two problems here.
1. its appending to a wrong url
2. it doesn’t have that page id appended to the page.
what am i missing?
Edit : i removed the home_url(‘/’) and it worked fine. i am right?
what if my permalink is post name instead of id?
Doesn’t matter, That’s why you’re using get_permalink(
).
its appending to a wrong url
Sorry – try just <?php $my_link = get_permalink(51); ?>
And your link markup is malformed. It should be:
<p><a href="<?php echo $my_link;?>">Privacy policy</a></p>
Yes. figured that out and thanks. but when i click on main nav. and if i rollover the privacy policy. it says the same link as i am on the current page.its like the url is still taking it be same as the page i m on.shld there be any reset?
You need to add this code outside of the the Loop.
its in footer.how do i know where loop ends. :/ i thought it was in index.php
I have a image in home.php and i gave it link like you told.its showing and clickable but get_permalinks has the page name but it comes to index.is it coz of inside loop too? how can i break out of it in home.php and footer.php
Do you understand the anatomy of the Loop?
like loop shows u every post,pages,names,dates etc.?
More specifically, you need to be able to recognise where the Loop starts and ends – especially in a situation like this. For example, the main Loop would not extend to the footer of the page in the vast majority of themes, so I suspect there might be a problem in your theme. Have a read of The_Loop.
yes i have looked at that. My theme is a child theme and the loop is inside the loop.php, whereas i do have home.php which have my custom div and the footer has my own code.
What’s the parent theme? Do you have a custom copy of loop.php in your child theme?
Twentyten. yes i have the loop.php in my child theme folder.