WordPress WordPress Theme Development Finishing Your WordPress Theme Adding Widget Areas to a WordPress Theme

Edely Gomes
Edely Gomes
4,485 Points

I am unable to edit my widgets.

I am unable to edit my widgets. I add then to a Page or Blog Sidebar, but after two seconds the fields to edit name, content, etc, disappears and all I have are the options to delete or close the widget.

I copied and paste the code from functions.php, as the video told me. I don't know what I did wrong or if it is a bug.

Could someone help me?

Hi Edely :)

Would you be able to copy and paste up the code from your functions.php :)

Craig

1 Answer

Edely Gomes
Edely Gomes
4,485 Points

Here. I think that is identical to the shown in the video.

<?php

add_theme_support('menus'); add_theme_support('post-thumbnails');

function wpt_excerpt_length( $length ){

return 16;

};

add_filter('excerpt_length', 'wpt_excerpt_length', 999);

function register_theme_menus(){

register_nav_menus(
    array(
        'primary-menu' => _( 'Primary Menu' )
    )
);

}

add_action( 'init', 'register_theme_menus' );

function wpt_create_widget( $name, $id, $description ) {

register_sidebar(array(
    'name' => __( $name ),   
    'id' => $id, 
    'description' => __( $description ),
    'before_widget' => '<div class="widget">',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="module-heading">',
    'after_title' => '</h2>'
));

}

wpt_create_widget( 'Page Sidebar', 'page', 'Displays on the side of pages with a sidebar' ); wpt_create_widget( 'Blog Sidebar', 'blog', 'Displays on the side of pages in the blog section' );

function wpt_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( 'main_css', get_template_directory_uri() . '/style.css' );

wp_enqueue_style( 'googlefont_css', 'http://fonts.googleapis.com/css?family=Asap:400,700,400italic,700italic');

}

add_action('wp_enqueue_scripts', 'wpt_theme_styles');

function wpt_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', 'wpt_theme_js');

?>