What is the best way to call a php page? I recently decided too hard code my nav but when I try calling the page it comes back with an error.
Fatal error: Call to undefined function get_header() in /home/testSite.co.za/testSite.co.za/wp-content/themes/theme/companyhistory.php on line 6
Code:
<div class="nav-wrap">
<ul class="nav">
<li><a href='http://www.testSite.co.za/' >Home</a></li>
<li><a href='#'>About us</a>
<ul class="subnav">
<li><a href='http://www.testSite.co.za/wp-content/themes/theme/companyhistory.php'>Company History</a></li>
</ul>
</li></ul></div>
Question: What is the best way to call a relative page for nav in WordPress?
Use get_permalink
this will work with permalinks too and therefore is dynamic
<div class="nav-wrap">
<ul class="nav">
<li><a href='http://www.testSite.co.za/' >Home</a></li>
<li><a href='#'>About us</a>
<ul class="subnav">
<li><a href='<?php echo get_permalink('page id'); ?>'>Company History</a></li>
</ul>
</li></ul></div>
REFER HERE FOR MORE : GET PERMALINK
A useful function: http://codex.wordpress.org/Function_Reference/get_template_directory
<a href="<?php echo get_template_directory()./companyhistory.php; ?>">
But why aren't you using a Wordpress page? If you create a page with the slug 'companyhistory', then just <a href="/companyhistory">
is sufficient.
This isn't at all the way Wordpress was intended to be used. As cfgm says, you should use a Wordpress page indeed. I would suggest to create a page "Company History" with a company-history slug, and then you can put a "page-company-history.php" in your template directory. Wordpress will then automatically use that PHP file.
Hope this helps.