Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

ie:

get_header(); ?>

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

        <div id="content" role="main"
< ?
$args = array(
  //QUERY OPTIONS GOES HERE//
);

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


        <?php if ( have_posts() ) : ? >
share|improve this question
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.