Support » Plugin: Q and A FAQ and Knowledge Base for WordPress » [Plugin: Q and A – FAQ Plugin] Filter Request

  • This is a great plugin and I have used it on many sites. One customer wanted me to put #’s in front of each question and a permalink at the end of the answer. So instead of REALLY hacking the plugin, I’ve hacked it the right way and was wondering if you would consider adding some filters to the plugin so this would be officially supported. This is what I did:

    $qa_shortcode .= '<div class="faq-title"><a href="'.get_bloginfo('wpurl').'?qa_faqs='.$postslug.'">'.apply_filters("qa_faqs_title",$title).'</a></div>';
    $qa_shortcode .= '<div class="faq-answer">'.apply_filters("qa_faqs_answer",$answer, $postslug).'</div>';

    Also, is there a reason that it’s ?qa_faqs= instead of the prettier /faq/?


    EDIT: and for interest, here’s my somewhat hackier code that I put in the theme’s functions.php to tie in to the new filters.

    global $faq_count;
    $faq_count = 0;
    function myfaqtitle($str) {
    	global $faq_count;
    	return $faq_count . ': ' . $str;
    add_filter('qa_faqs_answer','myfaqanswer', 10, 2);
    function myfaqanswer($str, $postslug) {
    	return $str . '<p class="faq-permalink"><a href="' . get_bloginfo('url').'/faq/'.$postslug . '">(permalink)</a></p>';

Viewing 3 replies - 1 through 3 (of 3 total)
  • Additionally it would be great if there would be a apply_filters for ‘the_content’ to get for example the codecolorer plugin working.

    I fixed it this way

    $qa_shortcode .= '<div class="faq-title"><a href="'.get_bloginfo('wpurl').'?qa_faqs='.$postslug.'">'.$title.'</a></div>';
    		$qa_shortcode .= '<div class="faq-answer">'.apply_filters('the_content', $answer).'</div>';

    @maxe___ under my proposed solution, you’d be able to do that, you’d just have to wrap the_content filter in a secondary filter.

    My client really wanted to make the questions into an ordered list so I ended up having to hack the plugin completely (which I really hate) but it would be nice to add filters for:

    qa_after_entry (whole entry)
    qa_before_entry (whole entry)
    qa_title (title itself, inside link)

    To provide the most flexibility for the end user

    Plugin Author Dalton Rooney


    @maxe___: In the newest development version of the plugin we changed the main query and as such, we’re using the standard WP functions for things like title, permalink, and content now. Does that help? You can test by downloading it here (Click “Development Version”)

    @sparkweb: Your suggestion is a great one, I’ll definitely add that to the to-do list.


Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Q and A – FAQ Plugin] Filter Request’ is closed to new replies.