Title: Blocking HTML parts
Last modified: January 30, 2020

---

# Blocking HTML parts

 *  Resolved [Christian Leuenberg](https://wordpress.org/support/users/cleuenberg/)
 * (@cleuenberg)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/blocking-html-parts/)
 * Hi there,
 * we are using Beaver Builder for creating our content pages and Relevanssi for
   the search which are working fine together in general. But we have some troubles
   with one BB module that renders a related posts block which will be indexed by
   Relevanssi. I would like to block the whole HTML node that holds this related
   content block. So I came across the two filters **relevanssi_post_content** and**
   relevanssi_excerpt_content** but I am not able to write the correct regular expression,
   I guess. My current code in the functions.php of our theme:
 *     ```
       add_filter( 'relevanssi_post_content', 'koe_rlv_pre_code', 10 );
       add_filter( 'relevanssi_excerpt_content', 'koe_rlv_pre_code', 10 );
       function koe_rlv_pre_code( $content ) {
           $content = preg_replace( '/<div id="related-stories-row"(.*)<\/div>/s', '', $content );
           return $content;
       }
       ```
   
 * As you can see, the surrounding div has the id **related-stories-row** which 
   I am trying to address. But it doesn’t work. Any tips for me?
 * Thanks in advance!

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Mikko Saari](https://wordpress.org/support/users/msaari/)
 * (@msaari)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/blocking-html-parts/#post-12383658)
 * The catch here is that when `relevanssi_post_content` and `relevanssi_excerpt_content`
   run, shortcodes haven’t been expanded yet, so the post content doesn’t have the
   HTML code yet, but instead the shortcodes BB uses internally.
 * That probably makes it slightly easier to just pluck out the shortcode for the
   unwanted module.
 * Pro tip: add a `var_dump( $content ); exit();` as the first line of the function,
   then go save a post, and you’ll see exactly what Relevanssi is seeing at that
   point.
 *  Thread Starter [Christian Leuenberg](https://wordpress.org/support/users/cleuenberg/)
 * (@cleuenberg)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/blocking-html-parts/#post-12384507)
 * Thanks [@msaari](https://wordpress.org/support/users/msaari/)! BB doesn’t use
   shortcodes and `var_dump( $content ); exit();` didn’t work as expected but instead
   I simply looked into the `wp_posts.post_content` database field in order to get
   the actual HTML code. Now I was able to find the code block and rewrite my preg_replace
   pattern in the function.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Blocking HTML parts’ is closed to new replies.

 * ![](https://ps.w.org/relevanssi/assets/icon-256x256.png?rev=3529670)
 * [Relevanssi - A Better Search](https://wordpress.org/plugins/relevanssi/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/relevanssi/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/relevanssi/)
 * [Active Topics](https://wordpress.org/support/plugin/relevanssi/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/relevanssi/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/relevanssi/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Christian Leuenberg](https://wordpress.org/support/users/cleuenberg/)
 * Last activity: [6 years, 5 months ago](https://wordpress.org/support/topic/blocking-html-parts/#post-12384507)
 * Status: resolved