Q7A Section With Dedicated Widget Area

I want to add the Q&A section plug-in to my buddypress installation as its own stand alone section. That is, I want the sidebar to display the categories and tags widgets - but I do not want the the widgets to show up on the other pages of the site. Is there an easy way to make this happen? I am using the Studio theme. Thanks for any help or suggestions.

  • Mason
    • DEV MAN’s Sidekick

    Hiya Ciara,

    John's method above is probably the easiest way. Although if you could also create custom page templates in your theme and then register a new sidebar in your theme just for the question/answer pages.

    The method would be something like this:
    1. Register a new sidebar area to your theme. Look in functions.php for your other sidebar registrations and just copy/paste to create a new one. Here's what it looks like in the studio theme:

    		'name'          => __( 'Question & Answer Pages', TEMPLATE_DOMAIN ),
    		'id'            => 'question',
    		'description'   => 'Question widget area',
    		'before_widget' => '<div id="%1$s" class="widget %2$s">',
            'after_widget' => '</div>',
            'before_title' => '<h3 class="widgettitle">',
            'after_title' => '</h3>'

    I placed the above starting on line 136 of the functions.php file.

    2. Create a sidebar-questions.php page Make a copy of sidebar-page.php and change it's name to sidebar-questions.php. Then open this new file and look at lines 8 & 9. Change 'sidebar-page' to 'question' (or whatever you entered in the ID field in the step above) and save the file.

    3. In the admin widget area add your question-specific widgets to the new 'Question & Answers Pages' widget area. After adding widgets you'll see them load only on any of your Q&A pages.

    Hope this helps!

  • Mason
    • DEV MAN’s Sidekick

    Each of the pages created by the QA plugin call for a 'question' sidebar. If one isn't found, it uses the default page sidebar.

    If you wanted to modify this even further (say have a sidebar for questions and a unique one for answers) you would need to copy the page templates from the plugin folder to your theme's root folder and then modify the sidebar they are calling from 'question' to 'answer' and then repeat the steps above to create an 'answer sidebar.

    The pages you're able to copy and edit in the theme (found in qa/default-themes/) are:

    Hope that helps. Thanks!

  • Ciara
    • Design Lord, Child of Thor


    I used your code and made the changes as necessary exactly as you mentioned. I have registered the sidebar and created the corresponding page and it shows up in the admin panel. When I add widgets to it, they are placed but do not show up in the actual Q & A section. The old widgets remain from the base widget page. Any ideas on why it isn't working? Thanks for your continued help.

  • Mason
    • DEV MAN’s Sidekick


    Please change the file name to sidebar-question.php. I made an error in my post above, at every point you should use the same word so register 'question', sidebar-question.php and make sure the qa plugin theme files have:
    <?php get_sidebar( 'question' ); ?>
    in them. If they are all the same exact word - it should all link up correctly. Let me know.


  • Ciara
    • Design Lord, Child of Thor


    Finally was able to make it work. I made a sight change to your suggested code in the functions.php file. Instead of using the following:

    'id' => 'question',

    it worked when I made the following change:

    'id' => 'sidebar-question'


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.