Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

WP Menu not showing in one page

Hi everybody.

So, I am in the WP Developmet course, and I created a Nav menu and add all the pages to it.

When I visit each section (frontpage, blog, etc) its working, but when I click WORK (a custom page), the menu is not showing any more.

Where should I fix this??

Thanks

Are you using a custom template for the page?

6 Answers

Ivan, you have a typo in your work template file. The beginning of the file looks like this:

            <?
/*
    Template Name: Work Page
*/
php get_header(); ?>

You need to move the "php" that is before the get_header() function call so that it looks like this:

<?php
/*
    Template Name: Work Page
*/
 get_header(); ?>

I am creating the template from scratch

post the code for the "Work" Template.

            <?
/*
    Template Name: Work Page
*/
php get_header(); ?>

<p>This is work.php</p>

<?php 
    $arg = array(
        "post_type" => "work"
    );
    $the_query = new WP_Query ( $arg );
?>

<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <h3><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h3>
    <?php the_field("description"); ?>
    <hr>
<?php endwhile; else: ?>

    <p>No hay posts.</p>

<?php endif; ?>

<?php get_footer(); ?>

            ```

post the code for the front page and the header as well please

FRONTPAGE

   <?php get_header(); ?>
   <p>This is front-page.php</p>
   <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <h3><?php the_title(); ?></h3>
       <?php the_content(); ?>
       <hr>
   <?php endwhile; else: ?>
       <p>No hay posts.</p>
   <?php endif; ?>
   <?php get_footer(); ?>
<!DOCTYPE html>
<html>
    <head>
        <title>
            <?php 
                wp_title( "-", true, "right" );

                bloginfo( "name" );
            ?>
        </title>
    </head>
    <body>

<p>This is the header</p>
<!--Screenshot 600*450 px -->

<?php 
    $args = array(
            "menu" => "main-menu"
        );
    wp_nav_menu( $args );
?>

Thanks! its working... still surprises me how strict this is lol