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

Goran Radoševic
Goran Radoševic
9,955 Points

Flexslider won't work

==========================================

functions.php

<?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' );
}


}

// 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' );

add_action( 'wp_enqueue_scripts', 'theme_styles' );

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

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

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

        register_sidebar( $args );

}


create_widget( 'Levi Footer', 'footer_left', 'Prikaži spodaj levo v footer-ju' );
create_widget( 'Sredina Footer', 'footer_middle', 'Prikaži spodaj na sredini v footer-ju' );
create_widget( 'Desni Footer', 'footer_right', 'Prikaži spodaj desno v footer-ju' );

==========================================

front-page.php

<?php get_header(); ?>

</div>
<div id="featured" class="clearfix flexslider">

<ul class="slides">
        <?php

            $args = array(
                'post_type' => 'aktualno'
                 );

    $the_query = new WP_Query( $args );

?>


<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <li style="background-color: <?php the_field('ozadje'); ?>">
                <div class="container">
                    <div class="grid_8"><img src="<?php the_field('prikaz'); ?>"></div>
                    <div id="featured-info" class="grid_4 omega">
                        <h5>Featured Project</h5>
                        <h3 style="color: <?php the_field('gumbi'); ?>"><?php the_title(); ?></h3>
                        <p><?php the_field('description'); ?></p>
                        <p><a class="btn blue" style="background-color: <?php the_field('gumbi'); ?>" href="<?php the_permalink(); ?>">View Project &rarr;</a></p>
                    </div>
                </div>              

            </li>

        <?php endwhile; endif; ?>

            </ul>
</div>

<div class="container clearfix">
            <div class="grid_12 omega">
                <h5>Novi?ke - Prireditve - Zanjimivost</h5>

                <?php   
            $args = array(
                'post_type' => 'post',
                'category_name' => 'novo',
                'posts_per_page' => 1,
            );

            $the_query = new WP_Query( $args );

            ?>

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

            </div>
            <div class="push_2 grid_10 omega clearfix">
                <article>
                        <?php get_template_part( 'content', 'objava' ); ?>
                </article>
            </div>

        <?php endwhile; endif; ?>

        <div class="grid_12 omega clearfix">
                    <div class="grid_6 recent-post">
                        <article>
                            <h5>Moja Dela</h5>

                            <?php   
            $args = array(
                'post_type' => 'post',
                'cat' => -5,
                'posts_per_page' => 1,
            );

            $the_query = new WP_Query( $args );

            ?>

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

                            <?php get_template_part( 'content', 'objava' ); ?>

                            <?php endwhile; endif; ?>

                        </article>
                    </div>

                <?php

                    $args = array(
                        'post_type' => 'aktualno',
                        'posts_per_page' => 1
                         );

                    $the_query = new WP_Query( $args) ;

                ?>

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

                    <?php get_template_part( 'content', 'aktualno' ); ?>

                <?php endwhile; endif; ?>

        </div>

    </div>

<?php get_template_part( 'content', 'misel' ); ?>

<?php get_footer(); ?>

==========================================

theme.js

jQuery(document).ready(function($) {
    $('.flexslider').flexslider();
});

Pleas help :/

3 Answers

Gautam Thapar
Gautam Thapar
5,265 Points

You can try using

is_front_page()

in place of

is_page( 'home' )

in both the instances.

Nick Pettit
STAFF
Nick Pettit
Treehouse Teacher

Hi Goran Radoševic,

Can you be more specific about what isn't working? What were you expecting to happen, and what's actually happening instead?

Also, if you could provide a link to a live version of this website, that would be very helpful as well. :)

Goran Radoševic
Goran Radoševic
9,955 Points

Here is live version :

http://polnapljuca.com/irena/ Simply refuses to correctly place the site that is associated with side AKTUALNO... Pls help :/.

Thank you in advance.

Gautam Thapar
Gautam Thapar
5,265 Points

Have you created a page with the title 'home'? and assigned it as the front-page?

Gautam Thapar
Gautam Thapar
5,265 Points

Seems like you haven't included flexslider js file.

Goran Radoševic
Goran Radoševic
9,955 Points

Yes i see but in functions.php i have code and home.php but still can see why can't load script...I have js folder with flexslider.js and theme.js.File with theme.js load i can see it but fleaxslider.js not load.... uf ah aaaaaa

Goran Radoševic
Goran Radoševic
9,955 Points

And flexslider.css also won't include...why?

Gautam Thapar
Gautam Thapar
5,265 Points

Yes i see but in functions.php i have code and home.php

Need some clarification, home.php is just a template file. You need to create a page from inside WordPress admin and title it 'home' and then assign the home template to this page. After that you need to assign the page as your front-page from settings > reading.

You did all this right?

Gautam Thapar
Gautam Thapar
5,265 Points

and then assign the home template to this page.

ignore the above statement, since it is the front-page you need to assign front-page template to it.