Multiple instances of nivo slider plugin

A better solution would be to create a “Project” post type and a custom taxonomy to separate the different types of projects.

I recently did this on my own website because I wanted a way to keep my projects separate from the rest of my content. I used jQuery cycle instead of Nivo but the concept is the same.

Custom post types have a built in user interface so it wont be confusing for your client to add new projects.

It will also allow you to customize the way the “Projects” are displayed using a single-project.php template file.

I won’t go into how to register post types because The Codex explains this very well but I will show you how to get all the attached images to the post and display them in the slider.

<?php   
//The following code is for a sample single-post_type.php
?>
<?php get_header(); ?>
<div id="content">

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <h1 class="project-title"><?php the_title(); ?></h1>
        
        <div class="entry">
            <div id="slider">
        
                <?php
                // This gets all the images attached to the current post inside the loop
                    $args = array(
                    'post_type' => 'attachment',
                    'posts_per_page' => -1,
                    'post_status' => null,
                    'post_parent' => $post->ID
                    ); 
                $attachments = get_posts($args);
                if ($attachments) {
                    foreach ($attachments as $attachment) {
                 
                echo wp_get_attachment_image($attachment->ID,'medium', false);
                }
                    } ?>

            </div> <!-- /slider -->
            
        <?php the_content(); ?>
        
    </div> <!-- /post -->   

    <?php endwhile; else: ?>
    <p><?php _e('Not Found','your_theme_name'); ?></p>

    <?php endif; ?>
    
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)