- This topic has 5 replies, 2 voices, and was last updated 3 years, 7 months ago by
Leo.
-
AuthorPosts
-
October 7, 2018 at 2:22 pm #695662
Daniel
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
GP Premium 1.7.2October 7, 2018 at 5:36 pm #695716Leo
StaffCustomer SupportHi there,
You can use this filter here:
https://docs.generatepress.com/article/using-columns-in-the-blog/#changing-the-number-of-columns
https://codex.wordpress.org/Conditional_Tags#A_Category_PageLet me know if this helps π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 11, 2018 at 2:33 pm #699048Daniel
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.
October 11, 2018 at 6:00 pm #699115Leo
StaffCustomer SupportSo if I understand this correctly, you are trying to turn the columns option off for some categories?
If so then this is the filter actually:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98column_layout%E2%80%99Let me know if this works or if you need help with the code π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/October 14, 2018 at 7:19 am #700618Daniel
Hi Leo,
Thanks for that, I’ve now been able to get it done.
I appreciate your help, keep up the great work!
October 14, 2018 at 10:21 am #700799Leo
StaffCustomer SupportNo problem π
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/ -
AuthorPosts
- You must be logged in to reply to this topic.