[Support request] bulk edit sidebar layouts

Home Forums Support [Support request] bulk edit sidebar layouts

Home Forums Support bulk edit sidebar layouts

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #609414
    Todd

    Is there a way to change sidebars layouts (go from none to right side bar on multiple pages) for a set of pages with a bulk edit feature that I have seen in some themes. Is there a snippet I can add for this? Thank you!

    GeneratePress 2.1.2
    GP Premium 1.6.2
    #609450
    Leo
    Staff
    Customer Support

    Hi Todd,

    Funny that you are asking for this. GP 1.7 (currently in private Alpha) has the exact feature that will accomplish this easily.

    The beta should be public sometimes soon if you can hold off for a bit.

    If not, then we’d have to use this filter for now:
    https://docs.generatepress.com/article/sidebar-layout/#using-a-function

    The condition you are looking for should be something like this:
    https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page

    Let me know if you need more info ๐Ÿ™‚

    #609499
    Todd

    I need to try it now, but glad to hear that it will be in 1.7! I added the following and it is giving me an error, do I have something wrong?

    add_filter( 'generate_sidebar_layout','tu_custom_category_sidebar_layout' );
    function tu_custom_category_sidebar_layout( $layout )
    {
     	// If we are on a category, set the sidebar
     	if ( in_category( '289' ) )   
     	 	return 'no-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }
    #609501
    Tom
    Lead Developer
    Lead Developer
    #609537
    Todd

    I get the following:

    Fatal error: Cannot redeclare tu_custom_category_sidebar_layout() (previously declared in /home/curious9/public_html/tvtg164363/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()’d code:2) in /home/curious9/public_html/tvtg164363/wp-content/plugins/code-snippets/php/snippet-ops.php(352) : eval()’d code on line 11

    #609687
    David
    Staff
    Customer Support

    Hi Todd, that error says you are declaring the same tu_custom_category_sidebar_layout function in another snippet – the names need to be unique.

    #610023
    Todd

    Thank you. I changed that and it is not creating an error now, but this still does not seem to be working to have a right sidebar show up on pages tagged. I put the page that I have tagged in the original forum submission. The snippet is below:

    add_filter( 'custom_generate_sidebar_layout','tc_custom_category_sidebar_layout' );
    function tc_custom_category_sidebar_layout( $layout )
    {
     	// If we are on a category, set the sidebar
     	if ( has_tag( 'sidebar' ) )    
     	 	return 'right-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }
    
    #610042
    David
    Staff
    Customer Support

    How are you adding the tag? The link provided is a page so doesn’t include tags.

    #610095
    Todd

    I have a snippet that adds categories and tags to pages. But I also tried it on a test post page here and the sidebar does not show up. http://tvtg164363.vortechsgroup.com/qwik-post-1

    #610107
    David
    Staff
    Customer Support

    Aah just noticed in your code, you have changed the name of the filter as well this: custom_generate_sidebar_layout should be generate_sidebar_layout

    #610200
    Todd

    This worked. GP rocks again! Much appreciated and Thank you!

    #610520
    David
    Staff
    Customer Support

    Glad we could help ๐Ÿ™‚

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