• Resolved silente08

    (@silente08)


    I have been using Custom Posts on https://flamel-forum.eu/ for a while. From the beginning, I have been struggling with having custom post types show up in the Gutenberg block Latest Posts. My solution was to add ‘post_type’ => array(‘post’, ‘custompost’) directly to the args of the function render_block_core_latest_posts in latest-posts.php (wp-includes > blocks). This works fine, generally, but has two disadvantages:

    • The custom posts are still not shown in the backend, while other post types are.
    • After any update of latest-posts.php, I obviously have to add the post type again.

    My questions would be: where can I add the post type, so it also shows in the backend? And how can I trigger these changes via functions.php of my child theme, so they are update-safe?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Last I knew, and hopefully they’re working on this, I believe the “Latest Posts” block isn’t meant for anything except “Posts”. So even WP core doesn’t support custom post types in it yet.

    So not much we can do here with CPTUI either. I assume if/when it gets added, it’ll all be seamless and no settings for a given post type will need to be edited to make it work in that block or whatever other block they may release with that intent.

    Thread Starter silente08

    (@silente08)

    Sure, ideally the block will support custom posts at some point. But until then, isn’t there any function I can add to my child theme to add that one custom post type to latest posts? I am already using my_cptui_add_post_types_to_archives, but I can’t figure out how to write something similar for latest posts.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I’m not aware of any filters/hooks/etc for this core block at this point, so I don’t have any snippets that would help with this.

    For what it’s worth, it does look like the “Query Loop” block does offer post type support, which is different from the “Latest Posts” block.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Add post type to Gutenberg Latest Posts’ is closed to new replies.