• Resolved jayceezay

    (@jayceezay)


    Is it possible to set a custom layout width on certain posts?

    Right now I’m using a full width site layout at 1800.

    For certain posts, for example all posts under category “Tutorials”, is it possible to set the width at 1200?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello @jayceezay,

    All the customizer settings in Astra can be filtered. Here is an example how you the value of Site Content Width can be changed using the filter.

    add_filter(
    	'astra_get_option_site-content-width',
    	function( $width ) {
    		if ( has_category('block') ) {
    			$width = 900;
    		}
    
    		return $width;
    	}
    );

    In this change the slug block to the slug of the category you want and change the value of $width as per your needs.

    You can change the if condition if customize this even further as you wish.

    Thread Starter jayceezay

    (@jayceezay)

    Hi @nikschavan ,

    Thanks! Good to know that it can be done in Astra. I mainly just blog and am not a developer, but I roughly get what you wrote above. Could you let me know where I should paste and insert the code you provided?

    Thanks again!

    Nikhil Chavan

    (@nikschavan)

    Hi @jayceezay,

    A simplest way I would recommend is adding this code snippet using a WordPress plugin Code Snippets. This page also gives more information about how you can add snippets using this plugin.

    Thread Starter jayceezay

    (@jayceezay)

    Thank you @nikschavan! That worked out well for me. The 900 container $width in your example was what I used. If I may pose another question – How do I set the sidebar as a certain percentage of the 900 container $width? Thanks again!

    Hey @jayceezay,

    You can add below custom code to manage sidebar width.

    add_filter( 'astra_get_option_site-sidebar-width', 
    	function ( $width ) {
    		if ( has_category('block') ) {
    			// This width is in percentage.
    			$width = 20;
    		}
    		return $width;
    	}
    ); 

    Just modify number 20 here as per your requirement.

    Please let me know if you have any further queries.

    Regards,
    Vikas

    Thread Starter jayceezay

    (@jayceezay)

    Thanks Vikas!

    You’re most welcome, @jayceezay! ??

    If you need any further help. Please do let us know.

    Regards,
    Sweta

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to set custom layout width on certain posts?’ is closed to new replies.