To get your posts to display in the Gutenberg editor, you’ll likely need to create a separate query specifically for your custom block. This is because Gutenberg doesn’t use the main query in the same way the front end does.
Something like this:
$args = array(
'post_type' => 'your_custom_post_type', // Replace with your custom post type
'posts_per_page' => 10, // Adjust as needed
);
$block_query = new WP_Query($args);
if ($block_query->have_posts()) {
while ($block_query->have_posts()) {
$block_query->the_post();
// Your code to display each post goes here
}
wp_reset_postdata();
} else {
echo '<p>No posts found.</p>';
}
Related Posts:
- Enable Gutenberg on custom post type
- Creating conditional blocks for WordPress Gutenberg
- Add class to Gutenberg Editor for Custom Post Types
- How to filter by custom post type on Gutenberg “Latest Posts’ block
- Gutenberg: Sidebar for specific post type
- Gutenberg how to make attribute to save to meta
- How to add button to post page WordPress 5.x
- WordPress Gutenberg-Block with ESNext (withState, withSelect)
- The editor has encountered an unexpected error. // TypeError: Cannot read property ‘prefix’ of null
- Display different gutenberg template from selected post attributes
- WordPress Rest API only returns content when posttype has editor capability
- Lock post meta block at the bottom of a custom post type
- How can I list all custom post types in a block
- Gutenberg Featured-Image-panel missing when user with custom role edits Custom Post Type
- Adding a Gutenberg-like custom field on a custom post type
- Classic editor showing in Gutenberg when creating a custom post type
- Creating template with h3 block (block editor)
- How To Enable Block Editor (Gutenberg) for Existing Post Type via functions.php
- How to make a custom taxonomy selectable in post publish area?
- show_in_rest false disable Gutenberg
- I can’t choose the custom taxonomy in my custom post type on Gutenberg
- Parent field missing from custom post type in the block editor
- How to get the parent of a non-hierarchical custom post type being edited in Gutenberg
- post_type_link not working in gutenberg
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Getting meta in editor plugin, and event triggering issue
- Save the post parent in a custom post type in Gutenberg
- WordPress CPT save metadata in gutenberg
- Can I override a CPT template on a per post basis with Gutenberg block editor?
- Query Post Object in WP Admin
- How to display “Category and Post_tag” component in a CPT Gutenberg edit screen?
- Combine multiple getEntityRecords calls
- Custom post type editor uses old tinyMCE
- Use core block functionality in a custom block gutenberg
- gutenberg message
- How do I assign a block template (.html) to a custom post type?
- Custom post type set default template using block editor
- CPT: Enable Gutenberg, but disable editor field
- Select custom post type do display from page editor
- How add Filter by Tags and by categories to custom post type in Gutenberg block
- Is it possible to add the Gutenberg block editor to a custom taxonomy?
- How to debug failing updates for custom post type?
- Some posts not displaying by taxonomy term
- Can you programme the selected page template to display block patterns automatically?
- Possible to limit internal link search to post types with Gutenberg editor?
- Custom Gutenberg block problem – This block has encountered an error and cannot be previewed
- getEntityRecords/useEntityRecords: How to use CPT metadata?
- Custom Block: Adding “Post Type” dropdown to Sidebar Settings
- What are the differences between custom post type and custom page templates?
- Defining capabilities for custom post type
- Does anyone have any frameworks to setup custom post types and related actions/filters?
- How to solve suspected memory issue in custom WordPress loop?
- Create Custom Post Type Archive Page with Sub Categories Navigation Sidebar
- Ordering Custom Post Types with WP_Query
- How to show the archive / post type description on Single templates
- Show listings from Impress Listing plugin in random order using taxonomy and terms
- Can’t edit custom post type
- redirecting improperly after updating custom taxonomy term when referring from CPT edit page
- Deleting Custom Posts & Meta Data on Uninstall
- Why is my site using index.php instead of archive?
- WooCommerce Customer Role Delete Custom Post Type
- Options page – dropdown of users
- Addition of custom option panel crashes Media Library & Admin Area
- Meta Data for Custom Post Type not saving
- Remove “show sharing buttons” metabox Jetpack from custom post type
- Serial Number Delivery System Using WordPress
- Custom post type causes php-error in php version 5.2.17
- Associate page w/ specific single post template?
- Custom Post Type Metadata Not Saving
- Custom Meta Box Causing Error: “Are you sure you want to do this? Please try again.”
- Iterating through Object Array to customise display of full custom taxonomy for custom post type
- When I choose category from dropdown then everything working fine.But in backend it checked only child not parent [closed]
- Keep getting logged out
- Create query for both custom post type and category
- Why do I need to register my custom post type a second time when flushing rewrite rules?
- Add parameters to Yoast SEO plugin schema in functions.php [closed]
- Use a different URL path / permalink for CPT
- allowing custom user role to access custom post type in wordpress admin
- Page not found on custom post type page for projects
- Insert custom taxonomy into category query
- How can i remove post type archive URL?
- Delete all custom posts then upload a new CSV of events
- Custom taxonomy archive slug overwrites static page
- Editor role isn’t seeing specific post type posts with only post_type parameter
- what file is required to be created in plugin folder in order to show all the post content of a CPT with the help of permalink
- How can draft post after 1 year
- Menu disappears with custom post type link
- Fetch posts list from fist CPT taxonomy term and list under 2. CPT
- shortcode order for event custom post type
- wp_list_categories() with attachment post types
- how to limit query_post to first page?
- How to query the content of a specific custom post type?
- create functions based on array values
- WordPress pagination URL
- Pagination not working on custom post type archive
- How do I provide a search form for a specific post type, that is capable of searching within custom fields of the specified CPT?
- Two Permalinks with one Taxonomy (custom taxonomy) and (custom post type -> custom taxonomy)
- Removing custom post type name from permalink
- One WP website as content source for several others
- How to get custom taxonomy from Custom Post Type to display in Post Block in Unlimited Elements