• Hi,

    I run a Taekwondo site and the instructors wanted to be able to have a question and answer area, so I stumbled across your plugin. I’ve been trialling it (currently hidden from users without direct url) but have been facing a few issues with it, the main thing being the drop down category box.

    As a stock 2.1.2 version, it lists all the categories with a count after it, regardless of whether there’s any questions in that category. The post count is that of page_type post rather than question, when a user clicks on one of the categories without posts, the entire theme css goes to pot with a 404, but if the category contains questions, it goes there ok (but the count’s still wrong).

    It seems to be based around the get_categories (); query in querys.php, in that by get_categories() it’s only returning all the categories (hiding the empty ones of course), surely there needs to be a custom_page_type=question query in there somewhere (and a count for those). I’ve been running through the code for a while, that and looking up the codex at wordpress and various other places, but I’m not that great at coding lol. The only real way I’d see it work is with something along the lines of foreach get_posts where post_type = question then loop through each for the categories and then implement the count.

    The only work around at the moment would be to have seperate categories for questions and posts or set a private question, though in theory we should be able to get it to work as above.

    Gav

    http://ww.wp.xz.cn/extend/plugins/question-and-answer-forum/

Viewing 4 replies - 1 through 4 (of 4 total)
  • I posted a question about this 4 months ago

    http://ww.wp.xz.cn/support/topic/display-on-categories-under-which-questions-can-be-asked?replies=8

    It was to be included in the next update but I’ve just come back to this plugin aftre finding none else that provide agood q&a and would love it to be fixed.

    Plugin Author trevorpythag

    (@trevorpythag)

    Hi, sorry about the delay – I missed the email for this post.

    Try replacing line 66 of querys.php ($categories = get_categories();) with

    $categories = get_categories(array(
    		'type' => 'question',
    		'orderby' => 'count',
    		'order' => 'DESC',
    		'hide_empty' => 0
    	));

    Also inside the foreach loop place the if statement
    if (get_option('q_cat_' . $cat->term_id) == "TRUE")

    so that the block of code reads

    $categories = get_categories(array(
    		'type' => 'question',
    		'orderby' => 'count',
    		'order' => 'DESC',
    		'hide_empty' => 0
    	));
    
    foreach ($categories as $category) {
    if (get_option('q_cat_' . $cat->term_id) == "TRUE"){
    		$loophtml .= '<option value="/?cat=' . $category->term_id . '&post_type=' . $q_question_post_type . '">' . $category->cat_name;
    		$loophtml .= ' (' . $category->category_count . ')';
    		$loophtml .= '</option>';
    	}
    }

    I this should only display the categories with questions in although the count will still be wrong. You can always delete the code that displays the count so that at least the plugin isn’t displaying incorrect information.

    I think the best way of implementing an accurate count would be to have a count for the number of questions in each category stored in the database and then increase it whenever new questions are asked. However, this would take a bit of time to set up.

    Hope this works,
    Dave

    Hi Dave,

    That code doesnt work as I’ve tried it. Please take a deeper look as I think its a great plugin and worth your time.

    In the meantime I’ve just removed the category listbox.

    Thanks!

    James

    Plugin Author trevorpythag

    (@trevorpythag)

    I haven’t been able to recreate your problem. What exactly is the error your getting and what setting do you have?

    Dave

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘[Plugin: Question and Answer Forum] Category drop down menu’ is closed to new replies.