[Resolved] Different Blog Layout for Categories

Home Forums Support [Resolved] Different Blog Layout for Categories

Home Forums Support Different Blog Layout for Categories

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #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.2
    #695716
    Leo
    Staff
    Customer Support
    #699048
    Daniel

    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.

    #699115
    Leo
    Staff
    Customer Support

    So 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%99

    Let me know if this works or if you need help with the code πŸ™‚

    #700618
    Daniel

    Hi Leo,

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

    I appreciate your help, keep up the great work!

    #700799
    Leo
    Staff
    Customer Support
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.