Site logo

Archived topic

display blog layout for different categories

7 replies · Started by Dmitry on June 8, 2020

Viewing posts 1–8 of 8

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/ ?

Hi there,

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

Yeah, indeed I do need help, please

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

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

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

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

You're welcome

This archived topic is closed to new replies.