Home > Software engineering >  How to delete HTML from excerpts in posts on homepage?
How to delete HTML from excerpts in posts on homepage?

Time:08-12

How Can I delete html tags in excerpts posts on homepage https://ptbo.edu.pl/ ?

I mean only HOMEPAGE (not in categories) because I'm changing this manually in posts editor.

My code looks now:

<?php if ( allium_has_excerpt() ) : ?>
            <div >
                <?php the_excerpt(); ?>
            </div><!-- .entry-summary -->
            <?php endif; ?>   

I want to make changes only on the home page

CodePudding user response:

My solution would be to leave the HTML tags but add this CSS to make them unnoticeable:

.home .entry-summary a {
pointer-events: none;
color: #3d3d3d;
}

.home .entry-summary strong {
font-weight: normal;
}

CodePudding user response:

Ok, I'm trying to solve this problem by using custom fields:

add_filter( 'the_excerpt', function ($original_excerpt) {
if ( !is_home() ) return $original_excerpt;
return get_post_meta(get_the_ID(), 'MYCUSTOMFIELD', true);

});

but not working corectly because the_excerpt is into directly content (not in listing on index.php)

  • Related