• Isn’t there a way to list author posts with the loop function like in this hardcode?

    <?php
    	$numposts = $wpdb->get_results("
    		SELECT guid, post_title
    		FROM $wpdb->posts
    		WHERE post_author = " . $curauth->ID . "
    		AND post_type = 'post'
    		AND post_status='publish'");
    ?>
    	<ul>
    <?php
    	foreach ($numposts as $numpost) {
    		echo '<li><a href="'.$numpost->guid.'">'.$numpost->post_title."</a></li>";
    	}
    ?>
    	</ul>

    Thanks.

Viewing 1 replies (of 1 total)
  • Not tested but you can use query_posts for stuff like this.

    $getPostsByAuthor = query_posts('ignore_sticky_posts=1&author=$curauth->ID&post_type=page&post_status=publish&orderby=title&order=ASC');

    You can also substitute author=$curauth->ID for author_name=YourName

    then print it out however with something like

    if ($getPostsByAuthor ->have_posts()) {
    	while ($getPostsByAuthor ->have_posts()) {
    		$getPostsByAuthor ->the_post();
    		print get_the_title();
    		print get_the_content();
    	}
    }
Viewing 1 replies (of 1 total)

The topic ‘List author posts without hardcode’ is closed to new replies.