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 WordPress Theme Development Building Page Templates in WordPress Creating Custom Page Templates in WordPress

shareyourpeace
shareyourpeace
3,244 Points

Sidebar Output has Pages, Categories, Archives.

This is at point 6:51 in the video.

http://imgur.com/s3MUSya

Here is the code: page-sidebar-left.php note: <h2 class="module-heading">Sidebar</h2>

<?php
/*
 * Template Name: Left Sidebar
 */
?>

<?php get_header(); ?>

<section class="two-column row no-max pad">
      <div class="small-12 columns">
        <div class="row">
          <!-- Primary Column -->
          <div class="small-12 medium-7 medium-offset-1 medium-push-4 columns">
            <div class="primary">

            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <h1><?php the_title(); ?></h1>
            <p><?php the_content(); ?></p>

            <?php endwhile; else : ?>
                <p><?php _e( 'Sorry, no pages found.'); ?></p>
            <?php endif; ?>
            </div>  
        </div>
        </div>
          <!-- Secondary Column -->
          <div class="small-12 medium-4 medium-pull-8 columns">
            <div class="secondary">    
                <h2 class="module-heading">Sidebar</h2>
            </div>
          </div>
    </div>
</section>

<?php get_footer(); ?>

7 Answers

Andrew Shook
Andrew Shook
31,709 Points

shareyourpeace, what exactly is your question. I looked at the image you linked and saw the warnings and errors. I the error at the top of the page is because you have:

add_action( 'wp_enqueue_scripts', 'my_theme_js' ); 

in your theme's function.php file, but you don't have a corresponding function call:

function my_theme_js(){}

anywhere inside your functions.php file.

The error on the right side is telling you that you must have a file in you theme called sidbar.php. You don't have to have anything in the file and you are not required to use it, but you must have a file called sidebar.php.

shareyourpeace
shareyourpeace
3,244 Points

Thank you for looking at this. I am following the tutorial exactly.

But I do call the function. See below.

function my_theme_styles() {

    wp_enqueue_style('foundation_css', get_template_directory_uri() . '/css/foundation.css'); 
    //wp_enqueue_style('normalize_css', get_template_directory_uri() . '/css/normalize.css');
    wp_enqueue_style('googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');
    wp_enqueue_style('main_css', get_template_directory_uri() . '/style.css');

}

add_action('wp_enqueue_scripts', 'my_theme_styles');

function my_theme_js() {
    wp_enqueue_script('modernizr_js', get_template_directory_uri() . '/js/modernizr.js', '', '', false );
    wp_enqueue_script('foundation_js', get_template_directory_uri() . '/js/foundation.min.js', array('jquery'), '', true );
    wp_enqueue_script('main_js', get_template_directory_uri() . '/js/app.js', array('jquery', 'foundation_js'), '', true );
}

add_action('wp_enqueue_scripts', 'my_theme_js');

I have a close up of the deprecation error. It discusses deprecation of the sidebar.php file.

http://imgur.com/IjJm8BI

In the path from this error, here is the code: lines 3252-3269 from the wp-includes/functions.php in my local folder.

     * @param bool $trigger Whether to trigger the error for deprecated files. Default true.
     */
    if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) {
        $message = empty( $message ) ? '' : ' ' . $message;
        if ( function_exists( '__' ) ) {
            if ( ! is_null( $replacement ) )
                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );
            else
                trigger_error( sprintf( __('%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );
        } else {
            if ( ! is_null( $replacement ) )
                trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', $file, $version, $replacement ) . $message );
            else
            trigger_error( sprintf( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.', $file, $version ) . $message );
        }
    }
}

Of course, I am new to WordPress Theme Development etc. So explanation will help. This is my sidebar output at this point.

http://imgur.com/lE0zWxz
Thanks again :)

Andrew Shook
Andrew Shook
31,709 Points

That's weird. The only time I have seen that error is when the add action is trying to call a function that doesn't exist. Is that error still showing up?

As for the deprecation error, the error says theme without a sidebar.php is deprecated. Meaning that if you are using wordpress 3.0 or higher you have to have a file in your theme called sidebar.php.

shareyourpeace
shareyourpeace
3,244 Points
  1. I just added a sidebar.php into my themeFolder. It is totally empty. I have no idea what to include.

Now when click contacts from the menu, it says 'Sorry, no results found'. Note: Recall, I was getting output in the left sidebar: pages, categories,

2. I looked in the projectFolder downloaded from the course: There IS. A sidebar.php file so I copied it into my local themeFolder.

sidebar.php
<!-- Secondary Column -->
<div class="small-12 medium-4 medium-pull-8 columns">
<div class="secondary">

    <?php if( !dynamic_sidebar( 'blog' ) ): ?>

        <h2 class="module-heading">Sidebar Setup</h2>
        <p>Please add widgets via the admin area!</p>

    <?php endif; ?>


</div>
</div>

Cleared the cache. Same result.

I am lost and confused. In the tutorial, we did not even create a sidebar.php as of yet.

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

You shouldn't need the sidebar.php at this point.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Try removing one of the closing divs before the second column.

shareyourpeace
shareyourpeace
3,244 Points

Tried it. Browser output the same when I click on the 3 bars (menu) then contact

'Sorry, no results.'

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

What template do you have selected for the contact page in the admin area?

Also, until the navigation is added in WP you will have to navigate to pages by going to the page in the admin area and then clicking to view the page.

The only reason I can think that those widgets are showing up is from code that comes later in the course that may have gotten copied prematurely.

shareyourpeace
shareyourpeace
3,244 Points

1. Pages > contact > quick edit I have 'left sidebar' chosen as the template.

2. This code had to be fixed in header.php

<?php wp_nav_menu(array('theme_location' => 'primary-menu'))?>

Between the <nav> tages.

Can you explain that line of code please ?

3. Yes, that makes sense about premature coding, since I had gone backward in the course to troubleshoot and I didn't delete everything.
But what exactly on that page - screenshot - would be considered the 'widgets' ? The 'search bar' ?

thanks Zac