[Resolved] display blog layout for different categories

Home Forums Support [Resolved] display blog layout for different categories

Home Forums Support display blog layout for different categories

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1320159
    Dmitry

    Hi!

    You have an amazing costumization in your theme to work with post & archives in Customizing ▸ Layout ▸
    Blog (Archives + Posts).

    Whats the easiest way to apply different settings for this part, depending on the blog category I want to display? It looks like I need to use some custom php like this https://docs.generatepress.com/article/option_generate_blog_settings/ ?

    #1320300
    David
    Staff
    Customer Support

    Hi there,

    yes the option_generate_blog_settings filter is the way to go.
    Let us know if you need help with that.

    #1320533
    Dmitry

    Yeah, indeed I do need help, please

    #1320572
    David
    Staff
    Customer Support

    What changes are you wanting to make? And where should those changes apply eg. ALL Category archives or a specific Category ? Let me know.

    #1321851
    Dmitry

    For example, for the “sketches” category I need to apply changes for the archive page and single post page.

    #1321876
    David
    Staff
    Customer Support

    So you would need to create 2 x functions. One for archives:

    add_filter( 'option_generate_blog_settings', 'dmitry_custom_sketches_archive_settings' );
    function dmitry_custom_sketches_archive_settings( $options ) {
        if ( is_category( 'sketches' ) ) {
            // Add your options ehre
        }
      
        return $options;
    }

    and one for single posts:

    add_filter( 'option_generate_blog_settings', 'dmitry_custom_sketches_single_post_settings' );
    function dmitry_custom_sketches_single_post_settings( $options ) {
        if ( in_category( 'sketches' ) ) {
            // Add your options ehre
        }
      
        return $options;
    }

    Note each of the functions has a different name. And they have a slightly different conditional tag ie.

    Archives = is_category( 'sketches' )
    Singles = in_category( 'sketches' )

    More info on WordPress Condtionalm Tags

    #1322056
    Dmitry

    David, thanks a lot! And thanks for the link about conditional tags, It really looks useful to handle that info for me!

    #1322125
    David
    Staff
    Customer Support

    You’re welcome

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.