• Resolved danielvierab

    (@danielvierab)


    I need to show the last post from every user in a specific category-slug.php templage.
    So far I only able to show last post from every user but without filtering them by category.
    Any help?

Viewing 1 replies (of 1 total)
  • Thread Starter danielvierab

    (@danielvierab)

    I found myself a way to do it
    <?php
    $blogusers = get_users_of_blog();
    if ($blogusers) {
    foreach ($blogusers as $bloguser) {
    $user = get_userdata($bloguser->user_id);
    $args=array(
    ‘author’ => $user->ID,
    ‘post_type’ => ‘post’,
    ‘post_status’ => ‘publish’,
    ‘posts_per_page’ => 1,
    ‘caller_get_posts’=> 1,
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post();
    if ( in_category(‘opinion’) || in_category(‘esta-pasando’) || in_category(‘nacional-opinion’) || in_category(‘internacional-opinion’) ) {
    ?>

    <div class=”autor”>
    <div class=”autor-thumb”>
    <?php echo get_wp_user_avatar(get_the_author_meta(‘ID’), ‘original’ ); ?>
    </div>
    <div class=”autor-bio”>
    <h2><?php the_author() ?></h2>
    <h3><?php the_title(); ?></h3>
    <?php the_excerpt(); ?>
    </div>
    </div>

    <div class=”clear”></div>

    <?php
    };
    endwhile;
    }

    }
    }
    ?>

Viewing 1 replies (of 1 total)

The topic ‘1 post by user with specific category page’ is closed to new replies.