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

BUG: Behaviour of Related Posts widget and block are not consistent #2796

Closed
burhandodhy opened this issue May 24, 2022 · 5 comments
Closed
Labels
bug Something isn't working low priority module:related-posts Issues related to the Related Posts functionality wp-core
Milestone

Comments

@burhandodhy
Copy link
Contributor

Describe the bug
The Related Posts widget doesn't show anything when the page is not is_single. However, the block does show the related posts. This is happening because we have a sanity check for the widget that checks if the page is not single then returns. https://github.com/10up/ElasticPress/blob/develop/includes/classes/Feature/RelatedPosts/Widget.php#L42

Steps to Reproduce

  1. Add Related Posts Widget and Block in footer.
  2. Go to front page.
  3. Widget doesn't render anything
@burhandodhy burhandodhy added the bug Something isn't working label May 24, 2022
@felipeelia felipeelia added the module:related-posts Issues related to the Related Posts functionality label May 26, 2022
@felipeelia felipeelia added this to the 4.3.0 milestone May 26, 2022
@JakePT
Copy link
Contributor

JakePT commented Jun 7, 2022

As discussed we probably don't want these to be consistent, since the block has uses outside of is_single(), so instead we can use a check for in_the_loop() || is_singular() so that at least we know that there is a relevant post to get related posts for. The legacy widget will remain unchanged because we don't want it to suddenly appear in places users did not expect it to.

@felipeelia I think that's where we ended up, right?

@chaselivingston
Copy link
Member

@JakePT let me know this isn't quite done. #2825 is a fix for a related issue but not this exact one.

@chaselivingston chaselivingston modified the milestones: 4.2.1, 4.3.0 Jul 6, 2022
@JakePT
Copy link
Contributor

JakePT commented Jul 20, 2022

I went to make this change but ran into an issue. in_the_loop() does not return true inside the Query Loop block, so checking in_the_loop() would stop the block from appearing when used inside the query loop block.

Alternatively I though I might be able to check the block for the postId context that's used inside the editor, since I could use that to determine if we were inside the query loop block, but that value does not seem to be available in PHP (it's in the class, but as a protected property).

Frankly I think there's an issue with Core here that might need to be resolved before we can reliably change the behaviour here.

@JakePT
Copy link
Contributor

JakePT commented Jul 26, 2022

There's an open issue regarding in_the_loop() in the Gutenberg repo: WordPress/gutenberg#32896 I've added a comment to hopefully revive it.

@felipeelia felipeelia modified the milestones: 4.3.0, 4.4.0 Aug 29, 2022
@felipeelia felipeelia modified the milestones: 4.4.0, 4.5.0 Nov 29, 2022
@NV607FOX NV607FOX assigned NV607FOX and MARQAS and unassigned oscarssanchez, NV607FOX and MARQAS Jan 24, 2023
@felipeelia felipeelia removed this from the 4.5.0 milestone Mar 1, 2023
@felipeelia felipeelia added this to the 5.0.0 milestone Mar 1, 2023
@felipeelia
Copy link
Member

Closing this one as there is nothing we can do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low priority module:related-posts Issues related to the Related Posts functionality wp-core
Projects
None yet
Development

No branches or pull requests

7 participants