Category page for Q&A plugin

This is a follow-up to an earlier post:

Here’s a workaround if anyone would like a “Categories” tab for Q&A:

1. Create a WP page for your categories to display and give it any title you think appropriate, like “Question Categories” perhaps.

2. In your favorite editor, register a new widget area in your theme’s functions.php and upload it:

register_sidebars( 1,
'name' => 'Page-Top',
'id' => 'my-page-top',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '<div class="clear"></div></div></div>',
'before_title' => '<h3 class="widgettitle">',
'after_title' => '</h3><div class="widget-content">'

3. Create a new page template by copying page.php and name it whatever you like. Add the following just after the call for the post-title (the first part ensures that the Q&A menu is displayed only if it’s your new “Question Categories” page, and the second part displays whatever widgets you will place in your new widget area):

<?php if (is_page('question-categories')): ?>
<?php the_qa_menu(); ?>
<?php endif; ?>

<div id="custom-page-top">
<?php dynamic_sidebar('my-page-top');?>

4. If you don’t want the page title to display on your Categories page, wrap the call to the post-title in your template like so:

<?php if (!is_page('question-categories')): ?>
<h1 class="post-title"><?php the_title(); ?></h1>
<?php endif; ?>

5. Upload your new template. :slight_smile:

6. Go back to edit your new “Question Categories” page and assign it your new template.

7. Go to Appearance > Widgets and drag the Q&A Categories widget into your new “Page-Top” widget area.

8. The really great thing about this method is you can now also use your new widget area to display any widgets you like under the title of any page you want using your new page template and the very useful Widget Logic plugin:

9. Have fun!

Note: if you name your new “Question Categories” page anything other than what is suggested in this post, remember to adjust the “if” statements in functions.php accordingly (steps 3 & 4).