WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Excerpt "Read more" modifying (6 posts)

  1. s0what
    Member
    Posted 2 years ago #

    Hello!

    I have problems modifying Read More for excerpt.
    I have following code to display posts:

    <?php
    $args = array( 'numberposts' => 4,'post_type' => 'offers' );
    $lastposts = get_posts( $args );
    foreach($lastposts as $post) : setup_postdata($post); ?>
    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    <?php the_excerpt(); ?>
    <?php endforeach; ?>

    And I am trying to use this filter:

    function custom_excerpt_more( $more ) {
    	return '[.....]';
    }
    add_filter( 'excerpt_more', 'custom_excerpt_more' );

    But nothing happens :( Where's a problem?

  2. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    Have you enabled excerpt support for your "offers" custom post type?

  3. s0what
    Member
    Posted 2 years ago #

    Yes, excerpt is displayed, but instead of "[.....]" I see "Continue reading →"

  4. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    What Theme are you using?

    Check functions.php to ensure that excerpt_more isn't already being filtered.

  5. s0what
    Member
    Posted 2 years ago #

    thank you Chip! I was using TwentyTen theme and this filter was already used :) so lame..

  6. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    thank you Chip! I was using TwentyTen theme and this filter was already used :) so lame..

    In that case, it's easy to override, by passing a higher priority. I assume the Twenty Ten filter uses the default priority (10), so try passing a priority of 11:

    add_filter( 'excerpt_more', 'custom_excerpt_more', 11 );

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.