10

So I have WordPress installed in a subdirectory of my website with permalinks set up.

I have my website set up like so:

-index.php
-style.css
-/contact
---index.php
-/blog
---(Wordpress installation)

So my problem is, whenever I use an <a href="../">Home</a> to link back to my homepage, it only works from my main blog page. If I go to a permalink post it takes me back to the blog home.

What I'm wondering is, is there a way to link back to the main page on both my blog home, and a permalink post? If i use ../../ it works on the post, but not the blog home.

I hope I worded this clearly enough, if I missed anything please let me know. Any help greatly appreciated, thanks.

Sidetracking
  • 209
  • 2
  • 5
  • 13

2 Answers2

28
<a href="<?php echo home_url(); ?>">Home</a>

See: http://codex.wordpress.org/Function_Reference/home_url

coderabbi
  • 1,981
  • 14
  • 16
0

You can use the home_url function: http://codex.wordpress.org/Function_Reference/home_url

I also recommend checking out the WordPress Function reference, and use the appropriate built in functions rather than inventing your own.

Edit: Not sure if you want to go back to the main index, or the WordPress index. If you just want to link back to your first index.php, you can simply use <a href="/>Home</a>

oal
  • 585
  • 4
  • 14