I have a page with profiles in which people can post or comment
on a post
. The problem is that if this user chooses to comment instead of post, he or she will not get an author page
until it has submitted a post. Is there a way to show the author page anyway? Because I have a function that shows the comments on the author page, but because it has no posts in it, that won’t show too…
I hope someone can help me out.
PS: I already tried several plugins, but those things didn’t work out.
FYI: this is default behavior of WordPress and I am using the default author.php
template which has an “if have posts
” loop, if not, loop-no-posts
loop. So the author page is not created is there is no post. That is the whole point.
Edit: my code:
<?php if (have_posts()) : ?>
<ul><?php
global $wpdb;
$user_id = $post->post_author;
$where = 'WHERE comment_approved = 1 AND user_id = ' . $user_id ;
$user = get_userdata($user_id);
?>
<?php while (have_posts()) : the_post(); ?>
<?php responsive_entry_before(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="post-entry"><blockquote>
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
</a>
<?php endif; ?>
<?php the_excerpt(); ?>
</article>
<?php responsive_entry_after(); ?>
<?php
endwhile;
/* get_template_part( 'loop-nav' ); */
else :
get_template_part( 'loop-no-posts' );
endif;
?>
<?php
$args = array(
'user_id' => $user->ID,
'number' => 10, // how many comments to retrieve
'status' => 'approve'
);
$comments = get_comments( $args );
if ( $comments )
{
foreach ( $comments as $c )
{
$output.= '<a href="'.get_comment_link().'">';
$output.= get_the_title();
$output.= '</a>';
}
echo $output;
} else { echo "bla";}?>
</div>
Modified from here.
Edit: Added OP’s code