Exclude class from custom excerpt
-
Hi there,
I am trying to exclude certain areas of pages from the custom extracts Relevanssi generates. I found the filter hook
relevanssi_excerpt_content
in the user manual which should be appropriate. I have included the provided snippet in my functions.php:add_filter( 'relevanssi_excerpt_content', 'rlv_remove_noindex_class' ); function rlv_remove_noindex_class( $content ) { return preg_replace( '#<(.*) class=".*?relevanssi_noindex".*?</\1>#ms', '', $content ); }
On one page I used the following content for testing:
<h1 class="relevanssi_noindex">Holzbau (Don't show this in excerpt)</h1>
However, the text Holzbau (Don’t show this in excerpt) still appears in the Relevanssi excerpts. In addition, I tried several regex examples from the web which select an element with class, but again none worked.
Do you have any ideas what else i could try?
Thank you and kind regards
- The topic ‘Exclude class from custom excerpt’ is closed to new replies.