• Resolved Manuel Sailer

    (@msailer)


    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:
    1. search-article (CSS class of the outermost article tag)
    2. excerpt_part (CSS class of the innermost span tag)
    • General tab -> Ignore HTML elements (not applicable but for testing):
    1. article outermost tag
    2. span 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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author pepe

    (@pputzer)

    Hi @msailer, the problem is that only parts of the page passed through certain WordPress filters are processed by wp-Typography, so the plugin never sees surrounding classes/tags in the template (as described in the FAQ).

    To disable wp-Typography filtering of the search results, you’d have return true for the typo_disable_processing_for_post filter hook on that page. How to best do that depends on how Relevanssi is implemented (if it’s using a special “real” page and page template, you could probably add this snippet to the beginning of the template):

    add_filter( 'typo_disable_processing_for_post', '__return_true' );

    Thread Starter Manuel Sailer

    (@msailer)

    Hi @pputzer,

    thank you for your quick reply and your suggestion how to work around this problem.

    As you found out yourself, @msaari was also very fast in providing a new version of the Relevanssi plugin that fixes the problem by ignoring the soft hyphens injected by wp-Typography. I think you’ll agree that taking this solution is the better choice as highlighting and hyphenation will both be there in the result.

    In the topic Highlighting works only in some search results you gave some interesting insights into wp-Typography and the problems that might occur regarding content filter hooks and priority or when doing everything later on the whole document – what would be my favorite solution.
    Maybe toying a little more with that idea and ongoing improvements in standard conformity of libraries and browsers may give the chance to implement it that way some time in future. ??

    So big thanks again from me to both of you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disable hyphenation for tag or class’ is closed to new replies.