WordPress post carousel

This code is taken from another answer but slightly modified to load your posts from the portfolio post type. This shows you how to load several posts and includes them in a slider. With some modification to the Loop you could out put the first X posts and cycle them using an offset parameter.

JavaScript

<!-- Include Unslider JS -->
<!-- YOU SHOULD INCLUDE WP JQUERY (ENQUEUE IT YOUR THEME) -->
<script src="https://unslider.com/unslider.min.js"></script>

<!-- Set up the necessary JS for the slider -->
<script type="text/javascript">
jQuery( document ).ready(function( $ ) {
    $('.banner').unslider({
        // Add other arguments here
        speed: 500
    })
});
</script>

CSS

<!-- Some basic CSS for the slider -->
<!-- Remember to add your own CSS styling -->
<style type="text/css">
.banner { position: relative; overflow: auto; }
    .banner li { list-style: none; }
        .banner ul li { float: left; }  
</style>

PHP (the Query)

<!-- Output the HTML for the slider -->
<?php 
// Do the custom WP_Query first
    $query = new WP_Query( 
        array (
            'post_type' => 'portfolio',
            'posts_per_page' => '-1',
            'meta_key' => '_thumbnail_id', // only pull posts with images

        )
    );

// if we have posts, display them:
if ( $query->have_posts() ) : ?> 


<!-- Some basic HTML for the slider
     Each slide is simply an <li>
     within a surrounding <ul>
     inside an encasing div -->
<div class="banner">
    <ul>

    <?php // While we have posts, output them as <li>'s
    while ( $query->have_posts() ) : $query->the_post(); ?>
        <li style="background-image: url(<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>);">
                <h1><?php the_title(); ?></h1>
                <p><?php the_content(); ?></p>          
        </li>
    <?php endwhile; wp_reset_postdata(); ?>
    </ul>
</div>

<?php else : ?>
    <!-- ENTER HTML IF THERE'S NO SLIDES HERE -->
<?php endif; ?> 

Now to get this working you can simply paste each of those code fragments into your template file (but I’ve included them separately in case you wanted to include in your theme’s CSS/JS files). You’ll need to modify the Loop to include the first 9 posts segment of the PHP code and CSS to fit your theme but this example should work. Also be sure to check out the full docs and options list for Unslider