- This topic has 8 replies, 3 voices, and was last updated 5 years, 2 months ago by
Leo.
-
AuthorPosts
-
January 9, 2021 at 7:09 am #1612233
Dev
Hello,
On a few single posts, I want to set my right sidebar width to 25, and my global right sidebar width is 30.
How can I make the right side bar width to 25 for a few posts?
Please let me know.
January 9, 2021 at 8:27 am #1612317David
StaffCustomer SupportHi there,
this topic explains:
January 9, 2021 at 9:08 am #1612371Dev
Hello,
I’m confused. Like I want to change the right sidebar width for the post id 27468, then in that case, what will be my CSS CODE.
I’m confused because I want to change the width only on a few posts and pages, not on the homepage, and the below CSS code is saying something about the homepage.
Can you please tell me the exact one I need to use?
add_filter( ‘generate_right_sidebar_width’,’tu_custom_right_sidebar_width’ );
function tu_custom_right_sidebar_width( $width ) {
// If we’re on the home page
if ( is_front_page() ) {
return 40;
}// Return the default
return $width;
}January 9, 2021 at 9:17 am #1612382David
StaffCustomer SupportDo you have a list of Post IDs that you want to make this change ?
Let me know and ill provide you the PHP code you require.January 9, 2021 at 9:30 am #1612394Dev
Hello,
Below is the post ids for now.
27026, 27468, 27225, 27104, 26930, 24603, 26853, 24763
But soon, I will add more post id’s in it. So at that time, do we need to change the PHP code? And how and where to add PHP code? I had never added PHP code, so I don’t know where and how to add it.
Please let me know.
January 9, 2021 at 9:37 am #1612397Dev
Hello,
I read how to add PHP code, but all ways are looking a bit risky to me as your posts say that the site can turn into blank white as well.
Can’t u give me CSS CODE rather than PHP CODE?
If not, then please suggest the safest way to add PHP CODE.
January 9, 2021 at 11:14 am #1612476Leo
StaffCustomer SupportPHP is the best method for this.
Try this:
add_filter( 'generate_right_sidebar_width','tu_custom_right_sidebar_width' ); function tu_custom_right_sidebar_width( $width ) { // If we're on the home page if ( is_single( array( 27026, 27468, 27225, 27104, 26930, 24603, 26853, 24763 ) ) ) { return 40; } // Return the default return $width; }I read how to add PHP code, but all ways are looking a bit risky to me as your posts say that the site can turn into blank white as well.
Code Snippets is the easiest and safest method as it prevents that issue:
https://docs.generatepress.com/article/adding-php/#code-snippetsJanuary 9, 2021 at 9:54 pm #1612735Dev
Thanks, it worked well. Great.
January 10, 2021 at 10:06 am #1613372Leo
StaffCustomer SupportNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.