Jack Lee
asked 8 years ago

1.I think it will be better if users can custom the output of  DW Questions & Answer widgets,example for the popular questions widget:

 $question_template='<li><a href="%permalink%" class="question-title">%question_title%</a>%asked_by%%author_link%</li>';
/*
Adding a filter hook to users of DW Question & Answer to change the widget HTML output.
*/
$question_template=apply_filters('dwqa_popular_question_template',$question_template);

/*
This array is a global variable be used in the three widgets of DW Question & Answer.
*/
$dwqa_widget_tmp_to_be_replaced=array(
'%permalink%',
'%question_title%',
'%asked_by%',
'%author_link%',
);
while ( $questions->have_posts() ) { $questions->the_post();

/*
echo '<li><a href="'.get_permalink().'" class="question-title">'.get_the_title().'</a>.__( 'asked by', 'dwqa' ).' ' . get_the_author_link() . '</li>';
*/
$question_variables=array(
get_permalink(),
get_the_title(),
get_the_title(),
__( 'asked by', 'dwqa' ),
'',
'',
);

$output=str_replace($dwqa_widget_tmp_to_be_replaced,$question_variables, $template);

echo $output;

}

fire it:

/**
* Change the template of the popular question widget.
*/
add_filter('dwqa_popular_question_template','dwqa_chang_popular_question_template',10,1);
function dwqa_chang_popular_question_template($question_template){

$question_template='<li><a href="%permalink%" class="question-title">%question_title%</a></li>';

return $question_template;
}

and you’d better do this for the other thress widgets.
2.the css class of the latest questions widget is:

echo '<div class="dwqa-popular-questions">';

I think you’d better change it for users.
 
Best wishes and Happy new year!
 
 
 
 
 

Jack Lee
replied 8 years ago

$output=str_replace($dwqa_widget_tmp_to_be_replaced,$question_variables, $template);/*SHOULD BE:*/$output=str_replace($dwqa_widget_tmp_to_be_replaced,$question_variables, $question_template);

Jack Lee
replied 8 years ago

$question_variables=array( get_permalink(), get_the_title(), get_the_title(), __( ‘asked by’, ‘dwqa’ ), ”, ”, );/*ABOVE CODE JUST FOR TEST*/

1 Answers
DominicStaff
answered 7 years ago

Awesome ! Thank you so much 🙂
Regards,

Powered by DW Question & Answer Pro