You could start with get_currentuserinfo
put this in the php
global $current_user;
$current_user = wp_get_current_user();
from here, you can use $current_user->ID where you want.
then create the wordpress query(please see http://codex.wordpress.org/Function_Reference/query_posts for more information)
example
query_posts(‘author=$current_user->ID&post_type=post’);
Thread Starter
roback
(@roback)
Okay, this is what I used to get the user info:
global $current_user;
get_currentuserinfo();
echo '<div style="padding:10px;">';
echo 'Username: ' . $current_user->user_login . "<br>";
echo 'User email: ' . $current_user->user_email . "<br>";
echo 'User first name: ' . $current_user->user_firstname . "<br>";
echo 'User last name: ' . $current_user->user_lastname . "<br>";
echo 'User display name: ' . $current_user->display_name . "<br>";
echo 'User ID: ' . $current_user->ID . "<br>";
echo '</div>';
most of that is just to display for testing purposes, but it displays the current user correctly.
Then I use this to get the query:
query_posts('author=$current_user->ID');
And then I used this loop to try to display things (keyword try!)
<?php //The Loop
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<p> <?php the_author('author=$current_user->ID') ?> </p>
<?php endwhile; else: ?>
..
<?php endif; ?>
The problem that arises is that it doesn’t display posts from that author it displays posts from any author and the most recent posts.
is there something wrong in what I am doing? Is the $current_user not being carried into the Loop?
Try query_posts('author=' . $current_user->ID);