Site logo

Archived topic

Different Blog Layout for Categories

5 replies · Started by Daniel on October 7, 2018

Viewing posts 1–6 of 6

Hi there,

I've got a question regarding category blog layout. I've applied the 'Display posts as columns' option within the Blog section, however I don't want this applied to all the categories.

Is there a way to have this option applied only to certain categories (i.e. Articles) and other categories have the standard post layout?

Great theme by the way, I like the layout and functionality.

Thanks

Hi Leo,

That doesn't seem to be quite it, as that filter changes the number of columns per category page. I'm interested in having the columns Blog view for posts for some pages, and the normal list view for posts applied to others.

Is it possible to dequeue the column view for certain categories using Code Snippets within the child theme? I'm asking as I wouldn't really know how to do it by amending the .php files within the template.

I've found this php function while searching through this forum:

function generate_dequeue_scripts() {

// If the category ID is 14, dequeue masonry
if ( is_category( '14' ) ) :
wp_dequeue_script( 'blog-scripts' );
wp_dequeue_script( 'jquery-masonry' );
wp_dequeue_script( 'blog-imagesloaded' );
wp_dequeue_style( 'blog-styles' );
endif;

}
add_action( 'wp_print_scripts', 'generate_dequeue_scripts', 100 );
add_action( 'wp_enqueue_scripts', 'generate_dequeue_scripts', 100 );

This is meant to remove the masonry Blog style for posts for specific category ID's, how can this be applied for the column Blog option?

Thanks in advance. Keep up the great work.

Hi Leo,

Thanks for that, I've now been able to get it done.

I appreciate your help, keep up the great work!

No problem :)

This archived topic is closed to new replies.