WordPress.org

Ready to get started?Download WordPress

Forums

WP Carousel
Specify excerpt length (and images) for skinless crousel (3 posts)

  1. katefosson
    Member
    Posted 2 years ago #

    I have the skinless carousel set up and it seems to be working well. The one thing I need to change is the length of the excerpt. Currently the text sometimes runs past the end of the div.

    I see that the content is pulling from the theme-jcarousel.php file...
    <?php echo $item['DESC']; ?>

    I tried to change this to the_excerpt in order to limit the number of words that show up (and add a 'read more' link), however that won't show the image in the teaser, which I want to have.

    Any advice for getting the content to fit in the box, and allow images?

    Thanks!

    *Here is the site so you can see what I mean: http://militaryoneclick.com/

    http://wordpress.org/extend/plugins/wp-carousel/

  2. sumolari
    Member
    Plugin Author

    Posted 2 years ago #

    $item['ID'] stores the ID of the post, so you can use WordPress functions to get the post's object and then show the excerpt.

    Other way to solve the problem is to "cut" the value of $item['DESC']. Something like:

    <?php echo substr( $item['DESC'], 0, 20 )."..."; ?>

    That code will print the first 20 characters of the string.

  3. katefosson
    Member
    Posted 2 years ago #

    Thanks for your help.
    I guess I don't know enough to call the right things...
    If I add 'ID' in place of 'DESC' the ID number shows up as the content. How would I go about displaying the excerpt?

    Right now I'm using this function for the blog section. Could I call something similar with a different custom_excerpt_length?
    (that solves the issue of cutting off words vs. characters...although it does not show images in the excerpt, which I need it to do)

    function new_excerpt_more($more) {
           global $post;
    	return '<a class="moretag" href="'. get_permalink($post->ID) . '"> <p>Read the full article...</p></a>';
    }
    add_filter('excerpt_more', 'new_excerpt_more');
    
    function custom_excerpt_length( $length ) {
    	return 150;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    Thanks again!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic