I have working on xx.xyz.com then my project is move on xyz.com

In which I have gave in project the previous link is as below


And now my link is as belows


I have tried to put link relative like


but its not working. Any suggestion regarding this?

  • Can you give some more details? Are you talking about theme files, plugin files or site content? – Welcher Sep 12 '14 at 12:48
  • I got its just a /?page_id=634 – Dhruvin Sukhadiya Sep 12 '14 at 12:50

You should be using home_url() ( or something similar ) in your links for theme files when linking to pages. This will allow the domain to change and not affect your hardcoded links - assuming the ID's are the same of course.

<a href="<?php echo home_url();?>/?page_id=634">Link</a>

Good luck!

  • Can you mark it answered? :) – Welcher Sep 12 '14 at 13:13
  • Sure Why not :) – Dhruvin Sukhadiya Sep 12 '14 at 13:14
  • this apparently does solve the issue for the OP, but it is still actually an absolute link. (Just to clarify, for anyone else who might be looking for this answer.) – KnightHawk Sep 12 '14 at 14:27
  • Agreed. However I believe that in this case he was looking for the relative path because he wasn't using the built-in WordPress methods that are made for this sort of thing. Which negates the need ( in this case anyway ) for relative urls. – Welcher Sep 12 '14 at 14:32

Declare first page id $page_id = 634; , because you will need it to get page url by id. You can put it directly into the method, but its better to separate it, its more neat.

Than you use ` inside of HTML href element to make a link to the page. You dont need to write absolute link, it is NOT recommended at all. When ever you can, try to avoid apsolute link/path/ etc...

$page_id = 634; 
<a href=" <?php get_page( $page_id ) ?> ">link text</a>
  • 1
    You should explain why this code answers the question. – cybmeta Sep 12 '14 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.