Disable hyphenation for tag or class
-
As hyphenation of wp-Typography results in problems highlighting matching keywords in search result excerpts of Relevanssi, I tried to disable hyphenation for these.
This is the source code of an example search result:
<article class="entry hentry search-article"> <div class="entry-inner"> <div class="entry-content-data"> <div class="entry-article-part entry-article-header"> <h2 class="entry-title entry--item"> <a href="[...]" title="[...]" rel="bookmark" class="plain_color">[...]</a> </h2> </div> <div class="entry-article-part entry-article-body"> <div class="entry-excerpt entry--item"> <p><span class="excerpt_part">Lorem ipsum dolor sit amet, ...</span></p> </div> </div> <div class="entry-article-part entry-article-footer only-more"> <div class="entry-readmore entry--item"> <a class="readmore-button" href="[...]" title="">Weiter lesen</a> </div> </div> </div> </div> </article>
But “Lorem ipsum dolor sit amet, …” will get hyphenated although I tried the following wp-Typography configuration settings (always one at a time):
- General tab -> Ignore CSS classes:
search-article
(CSS class of the outermost article tag)excerpt_part
(CSS class of the innermost span tag)
- General tab -> Ignore HTML elements (not applicable but for testing):
article
outermost tagspan
innermost tag
-
Template Stylesheet additional CSS
.excerpt_part { hyphens: none !important; }
Words do not wrap anymore but highlighting problem still exists.
What actually makes Relevanssi’s function for highlighting matching keywords in search results work is disabling hyphenation in wp-Typography’s Hyphenation tab.
But obviously this is no solution as both should work together: hyphenation at least in all posts and pages except search results pages and highlighting in search results.
- The topic ‘Disable hyphenation for tag or class’ is closed to new replies.