Theme Compatibility - CPTs
The theme compatibility feature needs to have the option to support CPTs, not just pages. It is convenient, but very limiting right now.
Have you tried this?:
below:
/**
*
* Use any of the following snippets depends on your need.
* You may target any specific post type or page type to load the fluent-community-frame.php
**/
// load fluent community frame only for single blog post
add_filter('fluent_community/template_slug', function ($templateSlug) {
if(is_singular(['post'])) {
return 'fluent-community-frame.php';
}
return $templateSlug;
});
// load fluent community frame only for post, blog index, category or taxonmy and author pages
add_filter('fluent_community/template_slug', function ($templateSlug) {
if(is_singular(['post']) || is_home() || is_category() || is_tag() || is_author()) {
return 'fluent-community-frame.php';
}
return $templateSlug;
});
// load fluent community frame for all the pages including posts, archives etc
add_filter('fluent_community/template_slug', function ($templateSlug) {
return 'fluent-community-frame.php';
}, 10, 2);
However, being able to create CPTs from community will be quite handy β¦
https://community.wpmanageninja.com/portal/space/community-meta/post/new-cpt-for-community
Jorge de los ReyesΒ I didn't see anything in that thread I could try, other than that addons plugin. Which really didn't implement very well, IMO.
David RisleyΒ yes. Sorry I was referring to the official git but the URL was wrong. Just updated so you can try it. Itβs a snippet from the fluent community Git docs
Jorge de los ReyesΒ Added my little support to it. Fingers crossed. π€
J VΒ appreciated! Letβs go πͺ
David RisleyΒ I'd be open to some feedback on the Pages plugin if you had any. It's a super early proof of concept so far from a complete solution. Future versions will have full custom CPT capability rather than just /page/
I created a code snippet that kinda does it, but this would be something that would be nice to have easily baked in. Like, an option in the FC settings where you could check off post types that you want to be able to select the FC templates for.
Bonus points for having the FC template auto-apply. π
But, this could be used for all kinds of things.
Problem is how would a page template be able to support any CPT without being programmed to know which fields, etc. and the desired layout for the CPT?
Removed my code since the code at the link Jorge de los ReyesΒ posted is much simpler.
In case it helps anybody, here's a down-and-dirty code snippet that would enable the FluentCommunity templates as options for a CPT:
add_filter( 'theme_clientdoc_templates', function( $templates, $theme, $post, $post_type ) {
if ( wp_is_block_theme() ) {
return $templates;
}
$templates['fluent-community-frame.php'] = __( 'FluentCommunity Frame', 'fluent-community' );
$templates['fluent-community-frame-full.php'] = __( 'FluentCommunity Full Width Frame', 'fluent-community' );
return $templates;
}, 9999, 4 );
In this case, the theme_clientdoc_templates filter is being used for a CPT of type "clientdoc". So, just change that part to match your own CPT.
David RisleyΒ I tried it, but it's not working