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?
- plugin /which one ?
- Use full reference e.g. www.testSite.com/home/testSite.co.za/wp-content/themes/theme/companyhistory.php
- Any other options would be great 🙂 Thanks
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.
Use
get_permalink
this will work with permalinks too and therefore is dynamicREFER HERE FOR MORE :
GET PERMALINK
A useful function: http://codex.wordpress.org/Function_Reference/get_template_directory
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.