I just saw that Twentig adds classes through the page. I’ve managed to add this as well on the CPT archive page via functions.php, but It’s not perfect.
I would love to see support for Custom Post Type on the Twentig plugin, It would be amazing!
I have two CPT on my blog and I’m planning to add a third, and It is not that easy to add this to every single one CPT.
(I’ve created the CPT via functions.php as well)
Hi Raul,
Thanks for the suggestion. We’ll see if we can add an option that allows CPT to inherit the blog options. Currently, Twentig doesn’t apply the blog Customizer options to CPT to not interfere with the design of third-party plugins.
To apply the grid layout to all your CPT, you can add the following PHP code in your functions.php file:
function my_custom_body_class( $classes ) {
if ( is_post_type_archive() ) {
$blog_layout = get_theme_mod( 'twentig_blog_layout' );
$classes[] = 'tw-blog-' . $blog_layout;
if ( 'grid-basic' === $blog_layout || 'grid-card' === $blog_layout ) {
$classes[] = 'tw-blog-grid';
$classes[] = 'tw-blog-columns-' . get_theme_mod( 'twentig_blog_columns', '3' );
add_filter(
'post_thumbnail_size',
function() {
return 'large';
}
);
}
}
return $classes;
}
add_filter( 'body_class', 'my_custom_body_class', 12 );
I hope the above is useful to you,
If you enjoy Twentig, please leave us a review 🙂
Maybe add a option to opt-out of customizing the CPT if the user is using a third-party plugin? I would love to see something like that!
And I can help testing if you guys need.
The code worked perfectly! I just couldn’t figure it out how to make all thumbnails on the CPT 16:9.
I’ll definetely leave a review!