WordPress Best way to call a page

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:

Read More
<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

Related posts

Leave a Reply

3 comments

  1. 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.

  2. 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