Title: cannot exclude element
Last modified: February 20, 2022

---

# cannot exclude element

 *  Resolved [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/)
 * Hi there,
 * I am unable to exclude classes.
 * Here is my HTML:
 * > [flameshot_screenshot](https://imgur.com/K5gfOgi)
 * and here are my settings:
 * > [flameshot_screenshot](https://imgur.com/KS6wiA9)
 * But links are excluded at the HTML elements as well, and that post entry title
   is a link, so widows shouldn’t be prevented on that link.
 * I have cleared the wp-Typography plugin cache, my grid cache, and all my other
   caches, CDN, etc…
 * Am I specifying something wrong in my settings?
    -  This topic was modified 4 years, 3 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
    -  This topic was modified 4 years, 3 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).

Viewing 15 replies - 31 through 45 (of 50 total)

[←](https://wordpress.org/support/topic/cannot-exclude-element/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/cannot-exclude-element/?output_format=md)
[2](https://wordpress.org/support/topic/cannot-exclude-element/page/2/?output_format=md)
3 [4](https://wordpress.org/support/topic/cannot-exclude-element/page/4/?output_format=md)
[→](https://wordpress.org/support/topic/cannot-exclude-element/page/4/?output_format=md)

 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15439638)
 * Hi,
    great, thanks, now the noTypo class is added to the title.
 * But look what happens:
 * > [flameshot_screenshot](https://imgur.com/j1HQTn3)
 * My current post title is dewidowed too as a result, and as a single word is hanging
   in the last row, it’s ugly.
 * That’s why I would need to limit dewidowing to a grid, or limit inclusion to 
   wpTypography.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15439655)
 * Is it possible to exclude classes like this:
    .related_grid_column .noTypo ?
 * Then I could restrict it to that grid.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15439661)
 * Oh no it’s not possible because .related_grid_column is in the HTML, not in the_title
   itself.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15439699)
 * You can always tweak the de-widowing parameters. But really, you are better off
   disabling it completely. What you intend to do is probably possible, but not 
   with your level of PHP/WordPress knowledge.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15439759)
 * Ok.
    Thanks for the advice.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15447651)
 * Now everything is okay, almost. the_content is included, the titles in my related
   posts are excluded, because all titles are excluded – using the global hook that
   you suggested.
 * But now I would need to re-include my titles in my breadcrumbs, because only 
   the related posts titles should be excluded.
 * Is there a way to make breadcrumbs an exception for this global hook that you
   suggested:
 *     ```
       function add_notypo_to_title( $title ) {
   
           return "<span class="noTypo">$title</span>";
       }
   
       add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
       ```
   
 * Something like add the class to the_title except if the_title is in the breadcrumbs.
 * That would solve my problem.
    -  This reply was modified 4 years, 3 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15447685)
 * But I was told it’s not possible to check where global hooks like this are used.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15469305)
 * Hi there,
 * The global function above is adding the span also in the backend titles:
    Screenshot:
 * > [flameshot_screenshot](https://imgur.com/SWSEegm)
 * What would be the correct conditional to add to exclude the backend?
 * Thanks in advance.
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15469362)
 *     ```
       if (! is_admin() ) {
           add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
       }
       ```
   
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15469407)
 * This is my code now:
 *     ```
       function add_notypo_to_title( $title ) {
          if (! is_admin() ) {
           return "<span class='noTypo'>$title</span>";
       }
   
       add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
       }
       ```
   
 * – it removes the span from the backend, but also from the frontend.
    PHP checker
   found no issues:
 * > [flameshot_screenshot](https://imgur.com/k7VrnSn)
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15469421)
 * Well, that’s not what I suggested.
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15470426)
 * Gotcha, corrected it to:
 *     ```
       function add_notypo_to_title( $title ) {
   
           return "<span class='noTypo'>$title</span>";
       }
   
       if (! is_admin() ) {
           add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
       }
       ```
   
 * Thanks!
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15470890)
 * Is there a way to exclude the current post in this filter?
 * I tried something like this:
 *     ```
       function add_notypo_to_title( $title ) {
   
           return "<span class='noTypo'>$title</span>";
       }
   
       $current_id = function_exists( 'vcex_get_the_ID' ) ? vcex_get_the_ID() : get_the_ID();
       if $title !== get_the_title( $current_id ) )  {
   
   
   
           add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
   
       }
       ```
   
 * But it results in a critical error.
 * I got inspired from this snippet:
 *     ```
       add_shortcode( 'bbpresscomments', function() {
           $output     = '';
           $current_id = function_exists( 'vcex_get_the_ID' ) ? vcex_get_the_ID() : get_the_ID();
           $topics = new WP_Query( array(
               'post_type' => 'topic',
               'posts_per_page' => -1,
               'fields' => 'ids',
           ) );
           if ( $topics->have_posts() ) {
   
               foreach( $topics->posts as $topic ) {
                   if ( get_the_title( $topic ) == get_the_title( $current_id ) ) {
                       $output .= do_shortcode( '[bbp-single-topic id="' . intval( $topic ) . '"]' );
                   }
               }
           }
           return $output;
       } );
       ```
   
 * Vcex is my theme prefix.
 * Then I tried something like this to limit adding the class to the title in my
   related posts (that would be the goal – but they are the same post type as the
   posts where I do want to widowing):
 *     ```
       function add_notypo_to_title( $title ) {
   
           return "<span class='noTypo'>$title</span>";
       }
   
       $referer = wp_get_referer();
                   $post_id = wp_doing_ajax() ? url_to_postid( $referer ) : $post->ID;
                   $related = get_post_meta( $post_id, 'related_post_ids', true );
   
   
       if (! is_admin() ) {
            if (  empty( $related ) ) {
   
   
           add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
   
       }
       }
       ```
   
 * But this also didn’t work.
 * I have also tried this to exclude the current post:
 *     ```
       function add_notypo_to_title( $title ) {
   
           return "<span class='noTypo'>$title</span>";
       }
   
       global $wp_query;
       $exclude = $wp_query->post->ID;
   
       if( $exclude != get_the_ID() ) {
   
           add_filter( 'the_title', 'add_notypo_to_title', 10, 1 );
   
       }
       ```
   
 * But this code will not add the class anywhere.
    -  This reply was modified 4 years, 2 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
    -  This reply was modified 4 years, 2 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
    -  This reply was modified 4 years, 2 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
    -  This reply was modified 4 years, 2 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
    -  This reply was modified 4 years, 2 months ago by [berry metal](https://wordpress.org/support/users/erikalleman/).
 *  Plugin Author [pepe](https://wordpress.org/support/users/pputzer/)
 * (@pputzer)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15471422)
 * Hi [@erikalleman](https://wordpress.org/support/users/erikalleman/), depending
   on your exact understanding of “the current post”, yes there are ways to achieve
   that, but this is all going way beyond wp-Typography support questions. Therefore,
   I’d ask you to direct your questions to the appropriate fora on this site (and
   perhaps read a few tutorials on WordPress programming concepts beforehand).
 *  Thread Starter [berry metal](https://wordpress.org/support/users/erikalleman/)
 * (@erikalleman)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/3/#post-15473071)
 * I will post to the other forums.
    Thanks.

Viewing 15 replies - 31 through 45 (of 50 total)

[←](https://wordpress.org/support/topic/cannot-exclude-element/page/2/?output_format=md)
[1](https://wordpress.org/support/topic/cannot-exclude-element/?output_format=md)
[2](https://wordpress.org/support/topic/cannot-exclude-element/page/2/?output_format=md)
3 [4](https://wordpress.org/support/topic/cannot-exclude-element/page/4/?output_format=md)
[→](https://wordpress.org/support/topic/cannot-exclude-element/page/4/?output_format=md)

The topic ‘cannot exclude element’ is closed to new replies.

 * ![](https://ps.w.org/wp-typography/assets/icon.svg?rev=2663995)
 * [wp-Typography](https://wordpress.org/plugins/wp-typography/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-typography/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-typography/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-typography/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-typography/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-typography/reviews/)

 * 50 replies
 * 2 participants
 * Last reply from: [berry metal](https://wordpress.org/support/users/erikalleman/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/cannot-exclude-element/page/4/#post-15476519)
 * Status: resolved