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

Davis Rousseau
Davis Rousseau
6,670 Points

Help flexslider not linking

I'm using my local host and I can't seem to get my slider to link not sure why.

<?php

// Load the Theme CSS function theme_styles() {

wp_enqueue_style( 'normalize', get_template_directory_uri() . '/css/normalize.css' );   
wp_enqueue_style( 'grid', get_template_directory_uri() . '/css/grid.css' ); 
wp_enqueue_style( 'googlefonts', 'http://fonts.googleapis.com/css?family=Sorts+Mill+Goudy:400,400italic' ); 
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );    
wp_enqueue_style( 'social', get_template_directory_uri() . '/css/webfonts/ss-social.css' );     

wp_register_style( 'flexslider', get_template_directory_uri() . '/css/flexslider.css' );
if( is_page( 'home' ) ) {
    wp_enqueue_style( 'flexslider' );
}

} add_action( 'wp_enqueue_scripts', 'theme_styles' );

// Load the Theme JS function theme_js() {

wp_register_script( 'flexslider', get_template_directory_uri() . '/js/flexslider.js', array('jquery'), '', true );
if( is_page( 'home' ) ) {
    wp_enqueue_script( 'flexslider' );
}   
wp_enqueue_script( 'theme_js', get_template_directory_uri() . '/js/theme.js', array('jquery'), '', true );

} add_action( 'wp_enqueue_scripts', 'theme_js' );

// Enable custom menus add_theme_support( 'menus' );

// Function for creating Widegets function create_widget($name, $id, $description) {

register_sidebar(array(
    'name' => __( $name ),   
    'id' => $id, 
    'description' => __( $description ),
    'before_widget' => ' ',
    'after_widget' => ' ',
    'before_title' => '<h5>',
    'after_title' => '</h5>'
));

register_sidebar( $args );

}

// Create widgets in the footer create_widget("Left Footer", "footer_left", "Displays in the left of the footer"); create_widget("Middle Footer", "footer_middle", "Displays in the middle of the footer"); create_widget("Right Footer", "footer_right", "Displays in the right of the footer");

?>

4 Answers

your code got output a little weird in the forum post, so it's hard to tell.

In the output above, all of this is on the same line: // Load the Theme JS function theme_js() {

If it's like that in your theme that would cause your js not to get pulled in as your function declaration is in a comment.

If not, are you getting any php errors or any errors in the console?

I did some research and it sounds like it could be a couple different things

1) Including jQuery twice. Is jQuery only being called once in your source code? 2) flexslider.js does not exist or incorrect path to flexslider.js. Does the link to flexslider.js appear in your source code? and if so does it take you to the file?

Davis Rousseau
Davis Rousseau
6,670 Points

this is the error i'm getting

Uncaught TypeError: Object [object Object] has no method 'flexslider' theme.js?ver=3.8.1:2 Consider using 'dppx' units instead of 'dpi', as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) follow_button.1392079123.html:1 Uncaught TypeError: Cannot read property 'user' of undefined twiget.js?ver=3.8.1:3 event.returnValue is deprecated. Please use the standard event.preventDefault() instead.

Davis Rousseau
Davis Rousseau
6,670 Points

changed all the wp_register_script to wp_enqueue_script now everything is working normal thanks