-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Related Posts on AMP: Lower-priority filter hooks are removed #13775
Comments
We've been looking at this as well, most likely thanks to a customer we have in common. :) Internal reference: 4412-gh-jpop-issues @kbrown9 has been spearheading this investigation so far, and here is what she's found so far:
|
Fixes #13775 The filter 'filter_add_target_to_dom()' removes itself from the 'the_content' hook. Then, a bug in Core causes the filter with the next highest priority to be skipped. For more information on the Core bug see: https://core.trac.wordpress.org/ticket/9968 To avoid this bug, remove the call to "remove_filter( 'the_content', array( $this, 'filter_add_target_to_dom'), ...)". Instead, just rely on conditionals in the 'filter_add_target_to_dom()' method to control when related posts are added to the content. Related posts should not be added to the content under these three condtions: 1. The post contains a Related Posts block. 2. The post contains a 'jetpack-related-posts' shortcode. 3. The 'get_the_excerpt' hook is being executed. This hook is executed when the related posts are being generated, and related posts should not be added to the related post content. These conditions are already handled by the 'filter_add_target_to_dom()' method. However, legacy related posts are currently added to posts that contain a Related Posts block. Fix this by removing the $content parameter from "has_block('jetpack/related-posts', $content)".
Thanks for the bug report @micropat! I just want to add an additional detail about this bug. If there are multiple filters with priorities greater than 40, only the first filter with a priority greater than 40 is skipped. All of the other filters are applied. For example, if you try this code, you’ll see that 'add_something_to_content_filter2’ is applied.
|
Fixes #13775 The filter 'filter_add_target_to_dom()' removes itself from the 'the_content' hook. Then, a bug in Core causes the filter with the next highest priority to be skipped. For more information on the Core bug see: https://core.trac.wordpress.org/ticket/9968 To avoid this bug, remove the call to "remove_filter( 'the_content', array( $this, 'filter_add_target_to_dom'), ...)". Instead, just rely on conditionals in the 'filter_add_target_to_dom()' method to control when related posts are added to the content. Related posts should not be added to the content under these three condtions: 1. The post contains a Related Posts block. 2. The post contains a 'jetpack-related-posts' shortcode. 3. The 'get_the_excerpt' hook is being executed. This hook is executed when the related posts are being generated, and related posts should not be added to the related post content. These conditions are already handled by the 'filter_add_target_to_dom()' method. However, legacy related posts are currently added to posts that contain a Related Posts block. Fix this by removing the $content parameter from "has_block('jetpack/related-posts', $content)".
Filter hooks with a low-priority number of
41
or greater are removed on AMP pages when the Related Posts module is activated and setup.Steps to reproduce the issue
functions.php
or similar.What I expected
SOMETHING BEFORE CONTENT.
should prepend content.SOMETHING AFTER CONTENT.
should append content.What happened instead
No additional content is added to content.
The text was updated successfully, but these errors were encountered: