lostprophetpunk Posted January 8, 2010 Share Posted January 8, 2010 I have come across a problem whilst integrating wordpress into my website. I have managed to get nav.php to be included in the root of the blog (www.example.co.uk/blog/), but when viewing a post the nav.php does not get included anymore as the directory would not go back as far. This is the current code for it... include_once('../nav.php'); So it works for www.example.co.uk/blog/, as the nav.php is in the main folder. But when it has something like www.example.co.uk/blog/2010/06/, it doesn't include it. How could I make the path so it is a direct path? I have tried doing the full address (http//www.example.co.uk/nav.php), that doesn't work. I have tried foing the short address (/nav.php), that doesn't work. If anyone could help me out that would be great. Quote Link to comment https://forums.phpfreaks.com/topic/187699-php-includes/ Share on other sites More sharing options...
ignace Posted January 8, 2010 Share Posted January 8, 2010 include_once($_SERVER['DOCUMENT_ROOT'] . '/nav.php'); Quote Link to comment https://forums.phpfreaks.com/topic/187699-php-includes/#findComment-990964 Share on other sites More sharing options...
lostprophetpunk Posted January 8, 2010 Author Share Posted January 8, 2010 That still doesn't work, but I appreciate your help. Quote Link to comment https://forums.phpfreaks.com/topic/187699-php-includes/#findComment-990980 Share on other sites More sharing options...
RaythMistwalker Posted January 8, 2010 Share Posted January 8, 2010 so nav is in the example.com/nav.php? if you use example.com/blog/page.php you need ../nav.php so basically you need ../ for each directory you go back so for example.com/2010/06/page.php you need ../../nav.php Quote Link to comment https://forums.phpfreaks.com/topic/187699-php-includes/#findComment-990996 Share on other sites More sharing options...
lostprophetpunk Posted January 8, 2010 Author Share Posted January 8, 2010 Thanks ignace, it did work after all. I found that the way I was doing my navigation system messed up the link to the current page it was on. Quote Link to comment https://forums.phpfreaks.com/topic/187699-php-includes/#findComment-990999 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.