WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using wti_like plugin and this is how i get the number(count) of post liked by the author

// Get the author object
$author = get_user_by( 'slug', get_query_var( 'author_name' ) );

// Get the post ids liked by the author
$like_ids = $wpdb->get_var("SELECT SUM(value) FROM {$wpdb->prefix}wti_like_post
            WHERE user_id = {$author->ID} AND value > 0
            GROUP BY post_id ORDER BY SUM(value) DESC");

echo (int)$like_count;

How can i query the posts liked by the author and use my post format to display them in my author.php template?


get_header(); ?>

    <section id="primary" class="site-content"> 

        <div id="content" role="main"
< ?
$args = array(

$wp_query->query( $args ); ?>

        <?php if ( have_posts() ) : ? >
share|improve this question
up vote 0 down vote accepted

Your query would be something like:

$post_ids = $wpdb->get_col( "SELECT DISTINCT post_id FROM {$wpdb->prefix}wti_like_post WHERE user_id = {$author->ID}" );

Then you can pass that array of post IDs as the post__in argument of WP_Query:

$args = array(
    'posts_per_page' => -1,
    'post__in' => $post_ids
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.