WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Remove shortcode from the_excerpt (3 posts)

  1. little_kostas
    Member
    Posted 7 months ago #

    Hello guys,
    i my frontpage i am using a custom query

    <?php if ( $the_query->have_posts() ) : ?>
    <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    <div class="news">
    <div class="date"><?php the_time( 'd.j.Y') ?>:</div>
    <div class="new"><a href="<?php echo the_permalink(); ?>"><?php the_excerpt() ?></a></div>												</div>									  <?php endwhile; ?>										  <?php wp_reset_query(); ?>										<?php endif; ?>

    I am also using a social plugin that shows social button before the content inside the posts. BUT this shortcode is also shown when i use the excerpt function. How do i disable this shortcode from showing??

    I have used the following with no lack.

    Also i used the following :

    function remove_shortcode_from_index($excerpt) {
      if ( is_home() ) {
        $excerpt = strip_shortcodes( $excerpt );
      }
      return $excerpt;
    }
    add_filter('the_excerpt', 'remove_shortcode_from_index');

    but it does not work.

    Any other idea??
    Thanks
    - Konstantinos

  2. dimitris33
    Member
    Posted 7 months ago #

  3. little_kostas
    Member
    Posted 7 months ago #

    I found a sollution, i dont know if its good but it worked.

    I used the following

    <?php echo get_the_excerpt(); ?>

    instead of the

    <?php the_excerpt(); ?>

    Maybe the get_the_excerpt return plain text??
    Anyway thanks!

Reply

You must log in to post.

About this Topic