WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a WordPress site which generates a menu at the top of the page with this:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

This line is located somewhere in a file called header.php.

(Location in wp-admin is: Appearance -> Editor -> Templates -> Header (header.php)

What i need to do is use the line i gave earlier:

<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) ); ?>

In a separate php file. So that when i navigate to: `http://mijnwpsite.com/justthemenu.php

That it only outputs the menu. No doctype or anything.

What steps do i have to take for this?

Thanks in advance.

share|improve this question
up vote 1 down vote accepted

You would require the path to wp-blog-header.php to access WordPress functionality in a standalone PHP file. So your justthemenu.php file should contain the following code.

    wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.