Hi @brunomac,
Thanks for the suggestion.
We have chosen not to include the is_archive conditional tag so that the classes related to the blog layout don’t appear on all archive pages. Including it would add the classes to WooCommerce product archive pages, Jetpack portfolio archive pages…
Which page(s) do you want to target?
Thanks for the quick answer.
On my specific case, I’ve created a custom post type (listing) and a custom advanced search form, and I want to display all listings posts with the grid/card layout, and on the search result pages as well.
So basically I added on the index.php, line 2562 the following:
if ( is_search() || is_archive() …
My question now is, how to make this without the risk of loosing this feature when the plugin is updated
Thanks in advance,
Assuming that you’ve created your own plugin or child theme (to create your CPT), you can add the following PHP code in one of your PHP files. That way, you won’t lose the modifications when you update Twentig.
function my_custom_body_class( $classes ) {
if ( is_search() || is_archive() ) {
$classes[] = 'tw-blog-grid';
$classes[] = 'tw-blog-' . get_theme_mod( 'twentig_blog_layout' );
$classes[] = 'tw-blog-columns-' . get_theme_mod( 'twentig_blog_columns', '3' );
}
return $classes;
}
add_filter( 'body_class', 'my_custom_body_class', 12 );
I hope the above is useful to you,
Have a nice day.
Thanks a lot for your feedback 😀
Great! If you enjoy Twentig, please leave us a review 😀