You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First, I must apologize for only having a passing familiarity with modern PHP in general and WordPress in particular.
I've put together a template that includes a sidebar that uses a query loop to render a blurb of text ("Site News"). Since I want the entire news there, I'm using a "Content" block rather than the default "Excerpt" block within the Post Template subtree.
It works well enough on some pages, namely the ones that only render a single article, but breaks on pages that use a query loop themselves.
Specifically, the "Content" block in the sidebar renders the entirety of the first item return by the main query loop.
After pasting various error_log() lines across an unfamiliar codebase and narrowing things down, I'm left staring at wp-content/themes/wecodeart/inc/gutenberg/blocks/post/class-content.php, specifically these 3 lines in render():
if ( ! in_the_loop() && have_posts() ) {
the_post();
}
If I comment these out, my problem disappears, and the sidebar consistently loads its Site News correctly across the site.
I'm sure there's a good reason for those lines to be added from the base render_block_core_post_content() function, but perhaps there might be an additional check to throw in there that'd allow templates to render arbitrary post contents anywhere while keeping its intended purpose.
I hope that makes sense.
The text was updated successfully, but these errors were encountered:
First, I must apologize for only having a passing familiarity with modern PHP in general and WordPress in particular.
I've put together a template that includes a sidebar that uses a query loop to render a blurb of text ("Site News"). Since I want the entire news there, I'm using a "Content" block rather than the default "Excerpt" block within the Post Template subtree.
It works well enough on some pages, namely the ones that only render a single article, but breaks on pages that use a query loop themselves.
Specifically, the "Content" block in the sidebar renders the entirety of the first item return by the main query loop.
After pasting various error_log() lines across an unfamiliar codebase and narrowing things down, I'm left staring at wp-content/themes/wecodeart/inc/gutenberg/blocks/post/class-content.php, specifically these 3 lines in
render()
:If I comment these out, my problem disappears, and the sidebar consistently loads its Site News correctly across the site.
I'm sure there's a good reason for those lines to be added from the base
render_block_core_post_content()
function, but perhaps there might be an additional check to throw in there that'd allow templates to render arbitrary post contents anywhere while keeping its intended purpose.I hope that makes sense.
The text was updated successfully, but these errors were encountered: