Title: Adding blocking behavior not working
Last modified: December 8, 2021

---

# Adding blocking behavior not working

 *  Resolved [schulle](https://wordpress.org/support/users/schulle/)
 * (@schulle)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/)
 * Hi team!
 * I love your plugin and I’ve been using it for years! I am implementing a consent
   management platform these days and ran into a problem on how to add the data-
   block-on-consent attribute to different embedds like instagram and youtube.
 * My idea was to implement it in two different ways of which none of them work:
 * **1. functions.php**
 *     ```
       add_filter( 'the_content', function( $content ) {
           if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
               $content = str_replace("<amp-instagram", "<amp-instagram data-block-on-consent", $content);
           }
           return $content;
       }, 1 );
       ```
   
 * **1. custom template single.php**
 *     ```
       $content = $this->get( 'post_amp_content' );
        $content = str_replace("<amp-instagram", "<amp-instagram data-block-on-consent", $content);
       ```
   
 * Is there any other way how to add that attribute to the AMP components?
 * Any help is much appreciated!
 * Best,
 * Jonas

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

 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/#post-15144572)
 * Hello [@schulle](https://wordpress.org/support/users/schulle/)
 * Thank you for the support topic, This can be achieved with [amp_content_sanitizers](https://amp-wp.org/reference/hook/amp_content_sanitizers/)
   filter.
 * I have created a [small plugin](https://github.com/milindmore22/amp-block-consent)
   to demonstrate how you can add attributes to Instagram and youtube embed.
 * You can add additional embeds using the [similar logic](https://github.com/milindmore22/amp-block-consent/blob/main/sanitizers/class-sanitizer.php#L26-L48)
 * Hope this helps!
 *  Thread Starter [schulle](https://wordpress.org/support/users/schulle/)
 * (@schulle)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/#post-15144682)
 * Amazing! Thank you so much for that. It helps a lot!
 *  Thread Starter [schulle](https://wordpress.org/support/users/schulle/)
 * (@schulle)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/#post-15144686)
 * Topic is resolved
 *  Plugin Support [Milind More](https://wordpress.org/support/users/milindmore22/)
 * (@milindmore22)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/#post-15147597)
 * [@schulle](https://wordpress.org/support/users/schulle/)
    Glad our suggestion
   is helpful, Open a [new support topic](https://wordpress.org/support/plugin/amp/#new-topic-0)
   if you face further issues, also feel free to [leave a plugin review](https://wordpress.org/support/plugin/amp/reviews/#new-post),
   we would love to hear your feedback.

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

The topic ‘Adding blocking behavior not working’ is closed to new replies.

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

 * 4 replies
 * 2 participants
 * Last reply from: [Milind More](https://wordpress.org/support/users/milindmore22/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/adding-blocking-behavior-not-working/#post-15147597)
 * Status: resolved