vahid
asked 9 years ago

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?

5 Answers
vahid
answered 9 years ago

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>

DominicStaff
answered 9 years ago

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 🙂

vahid moh
replied 9 years ago

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.

DominicStaff
answered 9 years ago

Please read more about WordPress Query here: http://codex.wordpress.org/Class_Reference/WP_Query

vahid moh
replied 9 years ago

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?

Guru
answered 9 years ago

You can use buddypress and the custom code from DW to make a listing of all the questions an author/contributor has asked

vahid moh
replied 9 years ago

isn’t there anyway to use it in WordPress without buddypress?

BigHug
answered 9 years ago

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

vahid moh
replied 9 years ago

so you mean for using this get_posts function I must have buddypress?

BigHug
replied 9 years ago

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).

vahid moh
replied 9 years ago

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() ??

BigHug
replied 9 years ago

You can replace it with specific ID of users ( author ID ) in your query loop.

weEatComplete
replied 6 years ago

Did anything ever get created for this?

weEatComplete
answered 6 years ago

Did anything ever get done with this?

Powered by DW Question & Answer Pro