Tobias Zink
asked 7 years ago

hi,
the plugin shows great, but i miss two main things:
1. a widget who shows the last questions (there is only a widget who show the most popular)
2. short tags (codex), for example “[show DWQA]” or “[show DWQA ask-a-question-form]” who insert the choosen plugin-conent in a single page
i hope you know what i mean. can you add this options?

4 Answers
DominicStaff
answered 7 years ago

Hello Tobias !
1. I added  here the shortcode for popular questions features:

function dwqa_shortcode_popular_questions( $atts ){

    extract( shortcode_atts( array(
        'number' => 5,
        'title' => __('Popular Questions','dwqa')
    ), $atts ) );

    $args = array(
        'posts_per_page'       => $number,
        'order'             => 'DESC',
        'orderby'           => 'meta_value_num',
        'meta_key'           => '_dwqa_views',
        'post_type'         => 'dwqa-question',
        'suppress_filters'  => false
    );
    $questions = new WP_Query( $args );
    $html = '';

    if( $title ) {
        $html .= '<h3>';
        $html .= $title;
        $html .= '</h3>';
    }
    if( $questions->have_posts() ) {
        $html .= '<div class="dwqa-popular-questions">';
        $html .= '<ul>';
        while ( $questions->have_posts() ) { $questions->the_post();
            $html .= '<li><a href="'.get_permalink( get_the_ID() ).'" title="'.__('Link to','dwqa').' '.get_the_title().'">'.get_the_title().'</a></li>';
        }   
        $html .= '</ul>';
        $html .= '</div>';
    }
    wp_reset_query();
    wp_reset_postdata();
    return $html;
}
add_shortcode( 'dwqa-popular-questions', 'dwqa_shortcode_popular_questions' );

  Please put it in “<plugins-folder>/dw-question-answer/inc/shortcodes.php” ( you can refer to this link for more info https://github.com/designwall/DW-Question-Answer/blob/58f84e70af444fdd3db56361dc9147ed295eab13/inc/shortcodes.php ) .
How to use this shortcode ? 
[dwqa-popular-questions number="5" title="Popular Questions" ]

with number:  The number of questions that will be displayed
       title:        Title displayed before list questions  
2. About short tags, we will discuss about this issue in the next version.
Regards,

Tobias Zink
answered 7 years ago

hey,
thank you for your answer!
the main-reason for 2. is, i can insert the script in a static page and add my own text overhead, i can seperate choose for exampler only the “ask a question form” and i guess it will adjust automatically to my sidebars.

Kido D
answered 7 years ago

Hi Tobias,  
Please update DW Q&A plugin to the latest version, then you can use the shortcodes to insert plugin-content to your pages. Syntax:

[short_code_name]

 Available DW Q&A shortcodes: 

dwqa-list-questions
dwqa-submit-question-form
dwqa-popular-questions
dwqa-latest-answers
dwqa-question-followers

Regards, 

Tobias Zink
answered 7 years ago

WOW – Thank you very much 🙂

Powered by DW Question & Answer Pro