Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

1 Answer 1

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.

<?php
    require('/wp-blog-header.php');
    wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary' ) );
?>
share|improve this answer
add comment

Your Answer

 
discard

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.