harsh deshmukh
asked 10 years ago

Hi There,
What is the short code of DW-QA Popular Questions and Related Questions.
I want to display recent questions and answer somewhere in my home page. Can you please help/suggest..??
 
Regards,
Harsh
 

harsh deshmukh
replied 10 years ago

As we have already widgets available.However I am looking for short code for the same.

Regards,
Harsh

5 Answers
DominicStaff
answered 10 years ago

Hi Harsh !
Currently, we do not have the short code for these yet. Will try to make in later updated versions.

harsh deshmukh
replied 10 years ago

Hi Dominic,

At this point of time it will be helpful if you just tell me what are the functions or the codes that is being used for Popular Questions and Related Question Widget. I just fell to dig into and try to get my job done.

harsh deshmukh
replied 10 years ago

I think widget.php is being called.. 🙂

harsh deshmukh
answered 10 years ago

Hi Dominic,  I tried below to create a short code, change in code can be seen in bold letters.I went to dw-question and answer/inc/widget.php and edited the code as below and latter i put [dwqa_shortcode] in my page/post to call this. I Think I am missing something. Can You please work a bit to get it done.    referance: http://codex.wordpress.org/Shortcode_API
 
 
class dwqa_Related_Question_Widget extends WP_Widget { /**
* Constructor
*
* @return void
**/
//[dwqa_shortcode]
function dwqa_Related_Question_Widget() {
$widget_ops = array( ‘classname’ => ‘dwqa-related-question’, ‘description’ => __(‘Show a list of questions that related to a question. Just show in single question page’,’dwqa’) );
$this->WP_Widget( ‘dwqa-related-question’, __(‘DWQA Related Questions’,’dwqa’), $widget_ops );
} function widget( $args, $instance ) {
extract( $args, EXTR_SKIP );
$instance = wp_parse_args( $instance, array(
‘title’ => ”,
‘number’ => 5
) );
$post_type = get_post_type();
if( is_single() && ( $post_type == ‘dwqa-question’ || $post_type == ‘dwqa-answer’ ) ) { echo $before_widget;
echo $before_title;
echo $instance[‘title’];
echo $after_title;
echo ‘<div class=”related-questions”>’;
dwqa_related_question( false, $instance[‘number’] );
echo ‘</div>’;
echo $after_widget;
}
} function update( $new_instance, $old_instance ) { // update logic goes here
$updated_instance = $new_instance;
return $updated_instance;
} function form( $instance ) {
$instance = wp_parse_args( $instance, array(
‘title’ => ”,
‘number’ => 5
) );
?>
<p><label for=”<?php echo $this->get_field_id(‘title’) ?>”><?php _e(‘Widget title’) ?></label>
<input type=”text” name=”<?php echo $this->get_field_name(‘title’) ?>” id=”<?php echo $this->get_field_id(‘title’) ?>” value=”<?php echo $instance[‘title’] ?>” class=”widefat”>
</p>
<p><label for=”<?php echo $this->get_field_id(‘number’) ?>”><?php _e(‘Number of posts’) ?></label>
<input type=”text” name=”<?php echo $this->get_field_name(‘number’) ?>” id=”<?php echo $this->get_field_id(‘number’) ?>” value=”<?php echo $instance[‘number’] ?>” class=”widefat”>
</p>
<?php
}
}
add_action( ‘widgets_init’, create_function( ”, “register_widget( ‘dwqa_Related_Question_Widget’ );” ) );
add_shortcode(‘dwqa_shortcode’,’dwqa_Related_Question_Widget’);

harsh deshmukh
answered 10 years ago

Hi Rambu,
Need One more help.
How we can get shortcode for recent question and recent answer: I tried for recent answer as below, but output is not coming correctly:
http://harsh031.0fees.net/ Please see recent answer field in my website.(here I am getting link for the answer) Code used is as below here i have removed the meta_key value in $args array:
function dwqa_shortcode_recent_answers( $atts ){ extract( shortcode_atts( array(
‘number’ => 5,
‘title’ => __(”,’dwqa’)
), $atts ) ); $args = array(
‘posts_per_page’ => $number,
‘order’ => ‘DESC’,
‘orderby’ => ‘meta_value_num’,
‘post_type’ => ‘dwqa-answer’,
‘suppress_filters’ => false
);
$answers = new WP_Query( $args );
$html = ”; if( $title ) {
$html .= ‘<h3>’;
$html .= $title;
$html .= ‘</h3>’;
}
if( $answers->have_posts() ) {
$html .= ‘<div class=”dwqa-recent-answers”>’;
$html .= ‘<ul>’;
while ( $answers->have_posts() ) { $answers->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-recent-answers’, ‘dwqa_shortcode_recent_answers’ ); and called it in same way we have done for popular question.
[dwqa-recent-answer number=”5″ ]   Please help/suggest.

Mohi Uddin
answered 9 years ago

I have create a questions answers website. My website is: http://answers.itinfoworld.org
I have to problems one is, subscriber can not see his posted questions and answers. I think it would be better if a subscriber could see his posted questions at a glance by clicking on his profile.

My another questions is: I can not fined any wedges DW categories to show.

dominic Staff
replied 9 years ago
  • If the subscriber of your site can not see the question and answer, you can log in to Dashboard > Q&A > Settings > Permission.
    After changing the permission, please check and let us know, if you still face there issue.

  • About the dwqa categories section as our site in here. The feature you mentioned are custom codes and made for only DesignWall website. If you want to have it, we are ready to help you as a custom work with a charge of fee.
    In case that you are still interested in the feature, please kindly let us know, we will check and estimate the time.
    Regards,
Mohi Uddin
answered 9 years ago

dw question answer plugins tag and categories is not working in my website. http://answers.itinfoworld.org/

Please help me.

dominic Staff
replied 9 years ago

About this issue, please send me username & password of your site (via private answer ) for further checking.

Powered by DW Question & Answer Pro