WordPress.org

Ready to get started?Download WordPress

Forums

Nivo Slider + posts from category (3 posts)

  1. NWTD
    Member
    Posted 2 years ago #

    I'm using the nivo slider to create a featured post section on my site.

    I'm using the following code to gather the posted from a category named "Featured"

    <?php
    global $post;
    $args = array( 'cat' => 3 ,'numberposts' => 5 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>
    <?php  wp_reset_postdata(); ?>

    This does not display correctly. This shows all the posts on a single slide and creates 5 slides for the nivo slider.

    If i change the code to:

    <?php
    global $post;
    $args = array( 'cat' => 3 ,'numberposts' => 5 );
    $myposts = get_posts( $args );
    foreach( $myposts as $post ) :	setup_postdata($post); ?>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    <?php endforeach; ?>
    <?php  wp_reset_postdata(); ?>

    Then it shows the proper number of slides and shows one post per slide.

    I assume my problem lies within the extra elements added of <h3></h3> and <?php the_excerpt(); ?>

    The end result would have a single post per slide to display the title, the excerpt, and the featured image of each post along with a button/link to the full post.

    Any help achieving this would be greatly appreciated! TIA

  2. NWTD
    Member
    Posted 2 years ago #

    Here's the link to the this dev site: http://nwtechanddesign.com/yea/

  3. NWTD
    Member
    Posted 2 years ago #

    bump

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.