How to… Word Press, Themes and NAVT

How It Works

The first executed line in index.php is usually a call to the WordPress function get_header(). The get_header() loads the header.php in your theme directory and the PHP statements in the header.php are executed. As one might suspect, the header.php creates the HTML header portion of the finished output.

Once the header is complete, index.php begins fetching the contents of the page from the database. Contents here refers to the stories, articles, pages and so on that will be displayed when the page is complete. The database calls are made inside a loop that terminates when all of the contents available has been retrieved. This area of the index.php is often referred to as the loop.

Once the loop has ended the next item on the agenda is usually the construction of the sidebar. This is accomplished by calling the WordPress PHP function get_sidebar(). The get_sidebar() function loads the sidebar.php file from your theme directory and the PHP statements in the file are executed. The last WordPress function call made by the index.php file is get_footer(). This function loads and executes the footer.php file.

Your Mileage May Vary

Depending on how your theme was constructed, the scripting for the navigation lists that appear in your theme can theoretically be located anywhere. We can narrow down the possible location by making an educated guess.

If your theme has a horizontal navigation bar then the scripting code is probably located in the header.php file If your theme uses a vertical navigation list, then the code is probably located in the sidebar.php file. These are the two standard locations for theme navigation used by theme designers.

To locate the actual line of PHP code for your theme’s navigation list in any of your theme files, do the following:

  • Open the PHP file with any simple text editor (Win users should use WordPad)
  • Using the editor’s Find or Search command, look for the word wp_list_pages

wp_list_pages is a core WordPress PHP function call. It will appear in the file with between the PHP statements:

<?php wp_list_pages('title_li=<h2>Pages</h2>' ); ?>

Once you’ve located the wp_list_pages function call, it can be supplemented with the NAVT plugin interface function call. I’m going to create an example of how to correctly add the NAVT interface function to a sidebar.php file.

1 Response to “How to… Word Press, Themes and NAVT”


  1. 1 theneuralinvestor

    Very interesting article.

    I have tried to hack my theme with the following code, but without success… basically i just end up with the site showing a blank page and no page source (suggesting a PHP code error)

    Here’s the code:

    <?php (if( function_exists(“navt_getlist”) ) {
    echo “Pages”;
    echo “”;
    navt_getlist(“external”);
    echo “”:
    }
    else {
    ?>

    <a href=”/”>Home

    <a href=”/”>Home

    Would be very grateful if you spotted anything wrong if you could let me know.

    Thamnks

Comments are currently closed.