Support » Fixing WordPress » Incorrect post type content is used on FSE frontpage template

  • Resolved skorasaurus


    The post content block displays content from the wrong post type on the frontpage of my website even though the correct post type is displayed in the site editor.

    I have a semi-custom block-based/FSE theme (current code) and I made a plugin registering a custom post type with custom capabilities.

    I want to display the latest published post from my custom post type on the frontpage of the website.

    I edited the frontpage template through the site editor and used a query loop block (consisting of a post content block) and set the query loop block to use the custom post type.
    The site editor (on the back end; when viewing the template) displays the post content (the 4 columns of stats) from mostly recently published post from my custom post type (‘metric’) as intended; as indicated in the image below:

    However, When I view the site’s homepage as an end user; the most recently published post content of the post type ‘post’ is displayed – not the post content of my custom post type.

    You can see in the image immediately above, that the outer class applied to the query loop is from my custom post type ‘metric’ although the post content is from my post type of post.

    I am able to publish and edit the custom post type as expected.

    When I create and publish a page containing a query loop for the custom post type (containing a post content block); the content from the custom post type does display; so my issue is only applicable in the frontpage template.

    I am to reproduce this issue on a separate wordpress install using the ’empty’ theme and my plugin; which leads me that I didn’t set the register_post_type parameters correctly but after reading the reference for register_post_type ; I am unsure of how to proceed.

    To Reproduce:

    • create a custom role: wp role create role_metrics role_metrics
    • Add capabilities to that role wp cap add role_metrics edit_metric read_metric delete_metric edit_metrics edit_other_metrics publish_metrics read_private_metrics create_metrics
    • add that role to relevant user (can be done in command below, 156142 is the relevant user_id; which you get by wp user list) wp user add-role 156142 role_metrics
    • Copy my theme and activate; or you can use another FSE theme and create a
    • Install and activate my plugin (or you could just place the function inside a theme’s function.php)
    • create and publish a ‘metric’ post (insert anycontent you wish)
    • View the front page of the website (e.g. example.test) You will see post content from your most recently published post type of ‘post’ instead of the ‘metric’ post type.

    I am using WordPress 6.1.1; Gutenberg 15.0.1; (I have the same issue when disabling Gutenberg)

Viewing 1 replies (of 1 total)
  • Thread Starter skorasaurus


    After further troubleshooting, I believe it is a bug within the block editor itself and reported it on github issues. The link also has more information and a reduced test case (roles and capabilities of the custom post type do not affect the issue).

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.