Hiding 'Continued' in the_excerpt()

I’m using a list group to display FAQs:

 <a href="FAQ" class="list-group-item">

        <h4 class="list-group-item-heading"><?php the_title(); ?></h4>

        <p class="list-group-item-text"><?php the_excerpt(); ?></p>

</a>

But the Sage excerpt_more() function was adding “Continued” outside of the list-group-item-text box.

My workaround is simply adding a class to the anchor in the function and setting to display:none.

function excerpt_more() {
  return ' &hellip; <a class="continued" href="' . get_permalink() . '">' . __('Continued', 'sage') . '</a>';
}
add_filter('excerpt_more', __NAMESPACE__ . '\\excerpt_more');

Like:

.list-group .continued { display: none }

Is there a way that would make more sense? Maybe sending an argument to excerpt_more?

TY, folks.

Nope, Sage is not adding the hyperlink outside your class. Take a look at the actual mark up that’s being generated. Look here, the_excerpt() is not wrapped in a p tag because it generates it’s own p tags.

I’m willing to bet that in your markup you have <p class="list-group-item-text"><p>, which is not allowed in HTML so your browser is closing your first paragraph tag since you can’t have a paragraph in a paragraph.

Do you mean the mark-up posted above? You’re right that the second <p> is being generated by the_excerpt(). Ideally I’d like it to be in the <p class="list-group-item-text">. Can you think of a way to prevent it from generating it’s own paragraph tag?

Can you not wrap it in a div with that class?

1 Like

Good thinking, man. Maybe even duh on my part. Will give it a shot and report back (if I remember to).