Sidebar Layout Glitch

Home Forums Support Sidebar Layout Glitch

Home Forums Support Sidebar Layout Glitch

  • This topic has 6 replies, 2 voices, and was last updated 8 years ago by Tom.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #177056
    Paul

    Hey Tom,

    I just noticed that one on my pages is displaying the sidebar *below* the page content even though the page has it’s Sidebar Layout setting set to ‘Content (no sidebars)’.

    Scroll down the page at http://www.sweetlandgs.com/gardening-classes/ and you will see the sidebar widgets.

    I checked my page code in the page editor and don’t see any extra opening or closing DIVs or anything. Any idea what could be causing this? It’s only happening to this one particular page. All the rest of the pages’ Sidebar Layout settings seem to be working fine.

    #177065
    Tom
    Lead Developer
    Lead Developer

    Hmm, that’s odd – have you added any custom functions?

    Could be a poorly coded plugin – any active plugins on the problem page?

    #177071
    Paul

    Ahh yes.

    I added the following to functions.php in my child theme:

    http://pastebin.com/rtH6vtMQ

    It was some code I found online and then customized a bit for better layout.

    Do you see anything in there that could be forcing the Sidebar Layout setting to break?

    • This reply was modified 8 years ago by Paul.
    #177149
    Tom
    Lead Developer
    Lead Developer

    Hmm, tough to tell, but I think if it was in there it would happen to more than one page.

    Are you using a plugin that’s in use on that one page and not the others?

    #177279
    Paul

    After looking further, it seems to be caused by the shortcode that is generated by the code in my functions.php file referenced above. When I remove the shortcode from the page, the sidebar disappears as it should. When I replace the shortcode to display the custom post type posts that I want to appear there (the list of gardening classes), the sidebar re-appears below the content.

    Now I’m not sure what I need to do to fix this. It’s not an issue I expect you to fix as it’s not your code, but if you have any ideas, they would be greatly appreciated.

    The reason I’m using this code is because I needed to add schema to my markup for events. To do this, I installed the WP Structuring Markup plugin ( https://wordpress.org/plugins/wp-structuring-markup/ ). What I didn’t know is that it would create a custom post type; to get content of that custom post type to appear on the Gardening Classes page, I needed to add the custom code referenced above in the pastebin link.

    I’m wondering if wp_reset_postdata() has something to do with it.

    Maybe rather than using a shortcode, I should add the code from the pastebin link as a hook instead? If that would be a better way to do it, how would I make that hook apply only to this one particular page (Gardening Classes)? I don’t want the classes to appear on every page.

    Thanks, Tom!

    #177280
    Paul

    Well, it’s probably not the most ideal way to do it, but I added

    #right-sidebar {
    display: none;
    }

    to the page’s custom CSS and that makes the sidebar disappear.

    ๐Ÿ˜€

    #177323
    Tom
    Lead Developer
    Lead Developer

    Hmm, not really seeing anything wrong with that code. I’ll have to play around with it to see if I can figure it out.

    For now, your fix will work just fine ๐Ÿ™‚

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