Skip to content
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

Output hooked to the_content is output after template parts in Block Based Themes #20342

Closed
johnstonphilip opened this issue Feb 20, 2020 · 1 comment · Fixed by #20343
Closed

Comments

@johnstonphilip
Copy link
Contributor

Describe the bug
If you hook extra output to the_content, like many plugins do, template_parts in block-based themes show that output after the template part is shown.

Screen Shot 2020-02-20 at 2 36 18 PM

To reproduce
Steps to reproduce the behavior:

  1. Create a block-based theme, with the header.html and footer.html in the block-template-parts directory, and the index.html file pulling those in.
  2. Add this code to a custom plugin:
function my_content_after_the_content( $the_content ) {
	return $the_content .
	'<div class="sharing_icons">I am hooked to the_content, to appear after every output of the_content</div>';
}
 add_filter( 'the_content', 'my_content_after_the_content' );
  1. View a post.
  2. Notice you see the hooked output after each template_part is shown.

Expected behavior
Things hooked to show after the_content only show after the_content of a post.

Desktop (please complete the following information):

  • OS: MacOS
  • Browser: Chrome Version 79.0.3945.130 (Official Build) (64-bit)

The use of this filter code should probably be removed:

return apply_filters( 'the_content', str_replace( ']]>', ']]&gt;', $content ) );

@johnstonphilip
Copy link
Contributor Author

johnstonphilip commented Feb 20, 2020

I opened a PR for this here:
#20343

johnstonphilip added a commit to johnstonphilip/gutenberg that referenced this issue Feb 21, 2020
…te parts

Remove prepend_attachment from filters run on content for post template parts

WordPress#20342
epiqueras pushed a commit that referenced this issue Feb 21, 2020
…te parts (#20360)

Remove prepend_attachment from filters run on content for post template parts

#20342
johnstonphilip added a commit to johnstonphilip/gutenberg that referenced this issue Feb 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant