Skip to content
This repository has been archived by the owner on Jun 14, 2022. It is now read-only.

Custom Post Types for Post Grid Blocks #245

Open
inakicalvo opened this issue Sep 30, 2019 · 8 comments
Open

Custom Post Types for Post Grid Blocks #245

inakicalvo opened this issue Sep 30, 2019 · 8 comments
Labels
enhancement New feature or request

Comments

@inakicalvo
Copy link

Nowadays seting up an archive template for CPTs takes quite a bit of work and some coding.

It'd be great to be able to use the Post Grid block to display a list of posts of a certain CPT, beyond regular posts and pages.

@mikemcalister
Copy link
Contributor

Hi there,

A few users have brought this up, but my hesitation is that CPTs usually require a very specific display of content. I'm not sure the post grid would be the best place to display custom content provided by CPT's unless it also had settings to account for these variables.

We're still open to the idea, but we'd need to flesh out how to handle very custom things in a generic way.

@inakicalvo
Copy link
Author

Yeah, I get it. When those CTPs look pretty much like regular posts, the Post Grid Block would be a good fit.; but for CPTs with very specif custom fields it would be not…

@WPprodigy
Copy link

WPprodigy commented Nov 10, 2019

Came here to say this :). Understandable that not all CPTs would play nice, but I'd say the majority are still using the normal WP title / content / excerpt / featured image / author, etc. So out of the box it would have good compatibility for the majority.

Optionally, some filters in here could also be nice: https://github.com/studiopress/atomic-blocks/blob/develop/src/blocks/block-post-grid/index.php#L15


For anybody needing this, the workaround is not super ideal but could also be much worse. I really like the atomic blocks implementation of this recent post block type, so I decided to stick with it. To add custom post type support, you can unhook the block registration (atomic_blocks_register_block_core_latest_posts) and re-hook it in yourself, only this time use an altered version of atomic_blocks_render_block_core_latest_posts() in the callback where you've changed the query and such. I'm just checking for a custom class I assign, and if found in $attributes['className'], changing the query and output a little. Tis hacky and will probably break at some point - you've been warned :).

@jordonrupp
Copy link

I would find this very useful with the same output but with all CPTs that are enabled with the REST API available. I've wished for this a few times during some recent projects. Many times I need to show a set number of featured posts from different CPTs along with other page content and a block would be idea for this scenario. For example, an about page that displays some blog posts, some team members, resource items, and press items with their respective posts being organized in CPTs. I see the complications with using this for an CPT archive and whilst that can be a bit of work I think archives are best defined in your theme using the template hierarchy. Thanks for considering this!

@rfair404
Copy link

rfair404 commented Jan 5, 2020

Just set up a site that uses AB post grid, and not having the ability to add CPT's seems like it isn't fully supporting core functionality. It wouldn't be too hard to add this capability either. is there a PR for this yet?

@mikemcalister
Copy link
Contributor

Hey folks, this is definitely still something we're looking at. As mentioned before, with so many people using Atomic Blocks and the post grid particularly, it isn't something we can just add without changing how the current block works.

CPTs can opt in or out of supporting various features such as featured images, author, excerpt, title, etc. The block UI should reflect this support so we aren't showing empty controls that don't toggle anything. Taking an unmeasured approach leaves us constantly revisiting the block to address these considerations. We'll definitely consider the ongoing interest into our roadmap!

@rfair404 I disagree with this line of thinking that the block is somehow not supporting core functionality. The core Latest Posts block would be guilty of the same. It would also mean that infinitely variable and customizable CPTs needed to be considered the same as posts and pages by every plugin, theme, and block created. This block is for posts and pages, currently, and it supports those well.

@BrookeDot
Copy link

Also came to GitHub to look for a filter to register my own CPT with this block. I don't think the block needs to support all registered CPT by default but should be filterable.

@mindctrl
Copy link
Contributor

mindctrl commented Mar 2, 2020

Just a note for later. In the case of supporting CPTs via a filter or similar, we need a way to allow for the same with custom taxonomies - or update our code to be smart enough to detect which taxonomies are attached to the selected CPT, along with the other features mentioned above.

@mindctrl mindctrl added the enhancement New feature or request label Mar 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants