• Resolved brunomac

    (@brunomac)


    Hi,
    can you add the option to display as grid in archive pages as well?
    I was able to do it by changing line 2562 from
    if ( is_home() || is_author() || is_category() || is_tag() || is_date() || is_tax( get_object_taxonomies( ‘post’ ) ) )
    to
    if ( is_archive() || is_home() || is_author() || is_category() || is_tag() || is_date() || is_tax( get_object_taxonomies( ‘post’ ) ) )
    but this change will be overwritten when you update the plugin :/

    thanks in advance

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Twentig

    (@twentig)

    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?

    Thread Starter brunomac

    (@brunomac)

    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,

    Plugin Author Twentig

    (@twentig)

    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.

    Thread Starter brunomac

    (@brunomac)

    Thanks a lot for your feedback ??

    Plugin Author Twentig

    (@twentig)

    Great! If you enjoy Twentig, please leave us a review ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display as grid in archives as well’ is closed to new replies.