Black Friday Sale! Get up to $40 off GP Premium!Learn more

[Resolved] Custom Sidebar Layout Filter Not Working

Home Forums Support Custom Sidebar Layout Filter Not Working

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #377571
    Paul

    Hi Tom and Leo;

    I tried using a sidebar filter in my child theme’s functions.php file to remove all sidebars from posts with the category slug ‘student-articles’ but it’s not working; the globally set right sidebar still shows on all these category posts. I flushed the cache too.

    Here’s my code:

    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 ( is_category( 'student-articles' ) )
     	 	return 'no-sidebar';
    
     	// Or else, set the regular layout
     	return $layout;
    
     }

    Any ideas? Maybe it’s not compatible with the current GP release? I note the article at https://docs.generatepress.com/article/sidebar-layout/ was last updated on December 24, 2016.

    GeneratePress 1.4
    GP Premium 1.4.3
    #377600
    Leo
    Staff
    Customer Support

    Hi there,

    That should still work as nothing has changed there.

    Can you link me to a page that’s not working?

    Thanks!

    #377606
    Jamal

    Hi Paul and Leo

    I think what needs to be checked here is if is_singular && in_category

    Agressively support the kind of work you want to see. Buy it. Talk about it. Review it.

    #377947
    Paul

    You got it Jamal! Thanks so much.

    #377962
    Paul

    Weird thing happened since I posted this request yesterday. Now my custom page headers aren’t working at all. I removed the above function from my functions file and still no custom page headers.

    #377966
    Leo
    Staff
    Customer Support

    Hmm the function shouldn’t have anything to do with page headers.

    Can you link us to the page?

    #377973
    Paul

    Update: I can set a GLOBAL page header to all posts successfully, but when I assign a different custom page header style to a specific category of posts, the global page header style is displayed on those category’s single posts instead. Can’t seem to override the global one by category.

    #377975
    Paul

    Leo,

    Click on any post in http://dev.ayurvedacollege.com/articles/ — these are all set to a Global page header (General Articles page header) with a Green background.

    Compare to the ‘student-articles’ category posts at: http://dev.ayurvedacollege.com/student-papers/ — this category uses a custom page header (Student Articles page header) with a Blue background. As you can see, the Global Green page header is being rendered instead even though that category has been set to the Student Articles page header.

    #378087
    Leo
    Staff
    Customer Support

    Hmm this page is just a normal static page and not a post? http://dev.ayurvedacollege.com/student-papers/

    #378391
    Paul

    Click on any one of the posts listed on that page to see the problem, Leo. Each one of those posts should have a Blue header with white H1 title in it.

    General articles (accessed via /articles) should have a Green header with title instead.

    #378443
    Paul

    I’ve moved this separate issue over to a new thread at https://generatepress.com/forums/topic/new-page-header-not-working-properly/

    Will tag the initial problem here as resolved. Thanks.

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