Wordpress post preview without the link "read more"

Asked

Viewed 210 times

0

Hello,

I am a beginner in the Wordpress platform, and I find myself in a situation where I do not want the link "Continue reading" in the previews of my posts.

To add the posts previews to the home, I used the following code:

<article class="article-noticia-home">
<?php
if ( has_post_thumbnail() ) { ?>
    <div class="noticias-home-image-container">
        <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
            <img src="<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>" />
        </a>
    </div>
<?php } ?>
<header>
    <h3 class="recent-blog-entry-title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>"><?php the_title(); ?></a></h3>
</header>
<?php the_excerpt(); ?>

So far beauty, but where do I put the "<?php the_excerpt(); ?>" it brings a part of my post and a link from Read more.

<article class="article-noticia-home">
<div class="noticias-home-image-container">
    <a href="http://cristalink.com.br/site/2016/05/04/titulo-noticia-04/" title="Título Notícia 04">
        <img src="http://cristalink.com.br/site/wp-content/uploads/2016/05/noticia04.jpg">
    </a>
</div>
<header>
    <h3 class="recent-blog-entry-title"><a href="http://cristalink.com.br/site/2016/05/04/titulo-noticia-04/" title="Título Notícia 04">Título Notícia 04</a></h3>
</header>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum justo ut quam posuere,
ullamcorper ultrices est sagittis. Morbi rhoncus, erat nec convallis pharetra, tellus urna pharetra tellus,
ut lacinia arcu enim vitae enim. Aenean faucibus, erat vel posuere commodo, purus purus dignissim nibh, 
in laoreet lectus Lorem ipsum dolor sit amet, consectetur adipiscing elit. … 
    <a href="http://cristalink.com.br/site/2016/05/04/titulo-noticia-04/" class="more-link">
        Continue lendo 
        <span class="screen-reader-text">Título Notícia 04</span> 
        <span class="meta-nav">→</span>
    </a>
</p>

How do I continue with only post preview, and without the link?

Thank you.

1 answer

1


Add this piece of code to your functions.php:

add_filter( 'the_content_more_link', 'bacon_more' );
    function bacon_more() {
        return '';
    }

It adds a filter to return nothing instead of read more

  • Dude I understood the functioning, but it’s not working, may have change in the call 'the_content_more_link' depending on the theme I’m using?

  • 1

    I was able to find :) the theme q I used another add_filter using the_content() to force the link. I changed the Function q already existed with the q you spoke above, with the Return '' in the variable that he himself created to add the post preview and the link. worked right, thank you very much :D

Browser other questions tagged

You are not signed in. Login or sign up in order to post.