Add class to 'Read More'

Hi,
Im trying to figure out how to add a class to my ‘Read more’ code in my functions.php… here is the piece of that code…
i can’t figure out the placement. Id like to style it individually from the excerpt. Thanks as always! Rena

  $excerpt = ( $show_excerpt ) ? '<div class="x-recent-posts-excerpt"><p style="color:initial;">' . preg_replace('/<a.*?more-link.*?<\/a>/', '', cs_get_raw_excerpt() ) . 'Read More >></p></div>' : '';

Hi Palila,

Thanks for writing in! You already have this CSS class assigned to it x-recent-posts-excerpt. If you need another class, you can add a space and place your second class name.

For example:
<div class="x-recent-posts-excerpt my-custom-css-class">

Hope that helps.

That class styles the entire paragraph. I want to style the excerpt and the "read more " seperately.

Hi @fatcatgraphics,

Thank you for the clarification, you can wrap the Read More >> in your code with span to add a class on it.

e.g.

$excerpt = ( $show_excerpt ) ? '<div class="x-recent-posts-excerpt"><p style="color:initial;">' . preg_replace('/<a.*?more-link.*?<\/a>/', '', cs_get_excerpt_for_social() ) . '<span class="more-link">Read More >></span></p></div>' : '';

Then use that class to style the Read More >> separately.

Hope it helps,
Cheers!

March 2021 Update: The above code example has been adjusted to account for a change to a function name.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.