Support » Plugin: Simple Page Sidebars » Use a generated sidebar elsewhere

Viewing 15 replies - 1 through 15 (of 19 total)
  • Plugin Author Brady Vercher


    Hi there,

    The plugin is mainly suited for use with pages and doesn’t provide a mechanism for overriding sidebars for posts within the dashboard. Can you explain a little more about your setup and what you’re trying to do so I can make the best suggestion?

    • Are you wanting your sidebar to vary between posts, or will all posts use the same sidebar?
    • Should your posts sidebar be different than the main blog page sidebar?
    • Are you trying to use this to create the sidebar and then make a change to your template to use the generated sidebar?

    I should be able to provide better feedback knowing the answers to those questions.



    First, thanks for the quick response (and the great plugin for that matter)

    Just so you know, here is my individual setup:

    The parent theme has only one sidebar, and I have been using the child theme to better suit our theme. Even though our blog is hosted in a separate WP installation, I know we are considering merging the posts into our main WP installation. So because of that I created a new post type and a separate category taxonomy.

    Ideally, I wanted to create/link sidebars on individual posts (not that they would change page-to-page, but my company changes there mind a lot and the option is always nice).

    So plan B was to just call the specific created sidebar on the single and category templates for that custom post type (since they needed their own templates anyways).

    So in quick, the answer to your questions:

    • Do I want them to very between posts? Yes (but that is probably a much bigger fix)
    • Is the post sidebar different then the blog sidebar? Yes (because it is a different post type)
    • Am I using the plugin to create sidebars then use in my template? Yes (because I figured question 1 and 2 would be a bigger hack)

    Thanks again for your quick response.

    Plugin Author Brady Vercher


    Thanks for the detailed response, Matt. Unfortunately, it sounds like most of what you need to do should be done in your child theme templates, or there are a couple of other sidebar plugins that are more advanced that might let you do everything from within the dashboard.

    However, if you’ve already created the sidebar using this plugin and you’d like to keep it simple and use it in your templates, the standard dynamic_sidebar( 'Generated Sidebar Name' ) template tag should work fine to display the custom sidebar.

    To modify it between posts, though, you’ll have to do a few if/else checks to call the right sidebar on the correct post and that can become unmanageable if there are a lot of them, especially if you have to arbitrarily register the sidebar with a page first. In that case, I’d definitely recommend seeing if there were a plugin more suited for using with posts.

    – Brady

    Yeah, unfortunately that looses all the registered argumets applied to the original sidebar.

    Your plugin is honestly really impressive, and I hope you continue to invest in it to eventually allow some more control (apply sidebars to posts/custom post_types).

    And I appreciate your quick response. I was expecting to not get an answer for a while.

    It looks like I’ll be registerring sidebars by hand, and loading them by meta-data attached to posts/pages.

    Thanks again for your help,

    Plugin Author Brady Vercher


    Hmm, I didn’t think about the custom sidebar inheriting the default sidebar’s arguments. Good point.

    Thanks for the compliments on the plugin. I originally named it the way I did so I could focus on providing an easy solution for a single sidebar on pages only, but I have thought about how it would work for all post types (and multiple widget areas on the same post/page). Unfortunately, I think it’d need to be rewritten to make it more generic.

    That being said, I think a couple of small tweaks would allow you to use this with posts if you would be ok with limited support (no quick edit/bulk edit, etc). Let me know if you’re interested in testing some quick changes out so you don’t have to implement a custom solution.

    I appreciate your help.

    I wanted to download your plugin not for myself, but for my bosses who want to be able to add/delete sidebars. I liked your plugin for it’s simplicity, but the simplicity came at the cost of no customization (like you said, not your goal so not your fault). I was hoping that since I was a developer I could just add some hooks to add some more options, but the hacks were getting pretty extensive so I just went ahead and used my own built-in functions.

    As for the custom version, I actually had already gotten it to where it would load/save on posts/custom post_types (for debug purposes), however I am doing everything in my power to not edit plugin/parent theme files. We normally just make our edits right on the original files, but I want to move away from that as a company, so that we can automatically update those files instead of having to do the updates by hand.

    Anyways, I’ll go ahead and mark this as resolved. If you wanna discuss anything else feel free to keep the conversation going.

    Plugin Author Brady Vercher


    I was thinking more of the lines of building the tweaks into the plugin and leaving them undocumented, sort of an Easter egg for developers that wanted to use the plugin and didn’t need anything more advanced, but wanted slightly more flexibility.

    It’s definitely a good policy to not edit plugins and parent themes directly if you want to continue receiving updates, so nice to see y’all move in that direction. And feel free to let me know if you see a place where a hook might make sense.

    In any case, I went ahead and pushed the tweaks I mentioned that should give you the ability to use this with additional post types. If you’d like to give it a shot, the update can be downloaded on GitHub. I’d like to do a little more testing before pushing it to the plugin directory.

    If you do decide to give it a go, you’d just need to do something like this to get it to work with other post types:

    add_action( 'init', 'prefix_init' );
    function prefix_init() {
    	add_post_type_support( 'post', 'simple-page-sidebars' );

    That’ll give you the Sidebar meta box on the Add/Edit Post screen.

    Let me know if that helps at all.

    The above code didn’t work on my installation.

    Just incase you are interested:
    1. Added code to functions.php
    2. Went to WP->Posts->Add New
    3. Verified sidebar meta-box missing from the “Screen Options” tab.

    Plugin Author Brady Vercher


    Did you download the update off GitHub and install it in place of your old version?

    whoops.. that was without your GitHub changes…

    Okay, changes work great. Will this get pushed here to wordpress?

    Plugin Author Brady Vercher


    Great! Yeah, I’ll push them eventually. If you’re running the update, you won’t get a notice though, since it’ll be the same version number.

    Okay. Thanks a bunch! This helps developers like me out a lot!

    Just as a really sloppy (but working) method for anyone searching for a way to use a sidebar on a template:

    before using the get_sidebar() call, query a page that uses the sidebar you want and then use the_post() right before the call. You can use wp_reset_query() after as well.

    So here is the new code:

    	query_posts('page_id=12'); // change to the ID of your page

    This will work for now.

    Plugin Author Brady Vercher


    That’s a pretty heavy impact to do something like this, so I wouldn’t recommend anyone use that code. Using query_posts() is typically frowned upon as well as there’s usually a better way to do what it does. Here are a couple of resources that should help clarify why it shouldn’t be used:

    I’d prefer to add a filter or a template tag to do this in a manner that’s much better for performance. If you don’t mind explaining where you’re trying to do this and why, I may be able to make a change or suggest a better alternative.

    • You already have the page id, so by default, you should know the id of the sidebar, right? Or are you wanting to allow the sidebar to change in the template if it’s changed for that page?
    • You can already change the default args that a sidebar is registered with if you’re needing those to match your theme’s defaults.
    • What kind of template are you doing this for? And is there a reason you don’t want to do it in sidebar.php?
Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Use a generated sidebar elsewhere’ is closed to new replies.