Skip to content

core/post-content block don't shows the correct content in pages (post type) #44981

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

Open
diegosomar opened this issue Oct 14, 2022 · 2 comments
Labels
[Block] Post Content Affects the Post Content Block [Type] Bug An existing feature does not function as intended

Comments

@diegosomar
Copy link

Description

If the core/query > core/post-content appears BEFORE the page core/post-content, it shows the page content instead the query loop item content.

This issue is probably related with #42862 and #40743.

Step-by-step reproduction instructions

  1. In the page (post type) tamplate, use the core/post-content to show the page content;
  2. Create a page and add some content;
  3. In the header template, add a core/query block to show a different post type and in the loop, add the core/post-content block.
  4. Go to the page and in the query loop you will see the current post content instead the query loop post content.

The query does not need to be in the header. It is enough that the query is above the content of the page, which will be enough to display the content of the page instead of displaying the content of the query.

Screenshots, screen recording, code snippet

wp-2022-10-14_10.22.14.mp4

Environment info

  • WP version: 6.0.2;
  • Plugins: only Gutenberg 14.3.0;
  • Theme: TT2;
  • Browser: Microsoft Edge (Ubuntu version).

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@carolinan
Copy link
Contributor

carolinan commented Oct 17, 2022

I am able to reproduce this with WP 6.1-RC1-54520, with and without Gutenberg active. I tried with a few different block themes.

  • It only affects the first post in the query
  • It doesn't happen with the post excerpt, only content
  • It doesn't make a difference if the page is set as the home page or not (reading settings)

@carolinan carolinan added the [Type] Bug An existing feature does not function as intended label Oct 17, 2022
@skorasaurus skorasaurus added the [Block] Post Content Affects the Post Content Block label Jan 26, 2023
@skorasaurus
Copy link
Member

skorasaurus commented Jan 26, 2023

I am admittedly fairly frustrated as I am experiencing this bug as well.

I want to display content from a custom post type on a website's frontpage and I cannot; content from the post type of 'post' is displayed instead.

Like @carolinan stated, this issue only affects the first post of the query loop but as a result of this bug, displaying content from a custom post type on the frontpage is futile. (if you alter your query loop to use an offset, the first post's content will still come from the post type of 'post'. regardless of what post type you select).

Interestingly, if you create the query loop (for the custom post type) and it is AFTER a query loop of post type post; the 2nd query loop will display content from the custom post type as intended.

An alternate, reduced test case :

Goal blocked by this bug: Display the post content from a custom post type's most recently published post on a website's frontpage.

  1. create and register a custom post type. An example, with a custom post type named 'metric' is available at https://gist.github.com/skorasaurus/cad69d2c05f8db300e2bea69b8eff026

  2. create and publish a new post of that custom post type. Any add content that you would like to your post's content.

  3. In frontpage template of your block theme:
    Insert a query loop and:

  • Select your custom post type (in this example, it is 'metric')
  • include the post content block as a child block in your query loop
    (example image is below)
    2023-01-26-test_case-site_Editor-query_loop

The content from your custom post type will display in the site editor.

  1. save your site editor changes.

  2. view the website as an end user; (e.g. example.test ) In the screenshot below, you'll see that the post content is from the post type of 'post' although the class given to the is from the custom post type (metric) and the post title from the custom post type is successfully retrieved and displayed

What I expected: The post content from my custom post type would display on the frontpage of the website.

2023-01-26-frontpage-of-same-query-loop-reduced_test_case jpg

I am able to to reproduce in WordPress 6.1.1; with and without Gutenberg 15.0.1 active; reproduced using the empty theme. and a custom FSE theme.

Technical context causing this is available at #42862 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Content Affects the Post Content Block [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

No branches or pull requests

3 participants