Hello I’ve created a custom author.php file for my wordpress site. how can I list all of the user questions and answers and comments in this page? which code should I use?
I finally found the code that I want!
to list all of questions:
<ul>
<?php
$curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author));
query_posts( array(
‘post_type’ => array(‘dwqa-question’),
‘author’ => $author )
);
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></a>
</li>
<?php endwhile; else: ?>
<p>no questions found</p>
<?php endif; ?><?php wp_reset_query(); ?>
</ul>
and to list answers:
<ul>
<?php
$curauth = (isset($_GET[‘author_name’])) ? get_user_by(‘slug’, $author_name) : get_userdata(intval($author));
query_posts( array(
‘post_type’ => array(‘dwqa-answer’),
‘author’ => $author )
);
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link: <?php the_title(); ?>”><?php the_title(); ?></a>
</li>
<?php endwhile; else: ?>
<p>no answers found</p>
<?php endif; ?><?php wp_reset_query(); ?>
</ul>
Hi,
Thanks for pointing on our question & answer forum ! Unfortunately, the DW Q&A plugin does not yet support a author page.
However, you can use Member list plugin to help you out. Please find the plugin here:https://wordpress.org/plugins/members-list/
Try it and let us know your experience, my friend 🙂
I don’t want to list users! I want to list questions of user.. There should be a php code which shows the questions that a user has asked.
Please read more about WordPress Query here:Â http://codex.wordpress.org/Class_Reference/WP_Query
sorry but I don’t have any information about this link. in designwall.com there’s a user profile which shows all of the things I’m searching for. is it possible that you add these features in your next version of plugin?
You can use buddypress and the custom code from DW to make a listing of all the questions an author/contributor has asked
isn’t there anyway to use it in WordPress without buddypress?
Hi vahid,Â
All section of user profile on designwall.com was made by buddypress, if you want an author page like this please integrate your theme with this plugin. About the list questions of specify user, you can use get_posts function of wordpress like this:Â
$questions = get_posts( array(
'posts_per_page' => -1,
'author' => bp_displayed_user_id(),
'post_type' => 'dwqa-question'
));
We do not support author page in features of DW Question Answer at the moment, we will consider to add it into the plugin in newer version of it.
Regards
so you mean for using this get_posts function I must have buddypress?
No, you dont need to. This function gets questions for you, and helps you to show the list of question to specific user ID, i refer buddypress because we use a buddypress function ( bp_displayed_user_id ) to get user id (in my sample code).
I don’t have Buddypress and I’ve made a custom author page (author.php) and added some codes to it (I got the code from another website) so that it shows the avatar and name and biography of user. so now which code should I use to instead of bp_displayed_user_id() ??
You can replace it with specific ID of users ( author ID ) in your query loop.
Did anything ever get created for this?
Did anything ever get done with this?
Please login or Register to submit your answer