• I’m working on a new build for a webcomic i do, and rather than having a pool of the recent posts on the front page i was wondering if there was a line that i could to draw only the latest post from a specific user, and repeat this line with different parrameters to display up to 4 users this way on the main page. does anyone have a fix for this?

    Asking here is a last resort i have been reading through docs for the last few hours with much angst. please and thank you.

    -Simplexunlocked

Viewing 9 replies - 1 through 9 (of 9 total)
  • Use as needed:

    <?php
    //get all users, iterate through users, query for one post for the user, if there is a post then display posts title, author, content info
    $blogusers = get_users_of_blog();
    if ($blogusers) {
      foreach ($blogusers as $bloguser) {
        $args = array(
        'author' => $bloguser->user_id,
    	  'showposts' => 1,
    	  'caller_get_posts' => 1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          // $user = get_userdata($bloguser->user_id);
          // echo 'This is one post for author with User ID: ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname;
          while ($my_query->have_posts()) : $my_query->the_post(); ?>
            <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
            <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?> </small>
            <?php
            the_content();
          endwhile;
        }
      }
    }
    ?>
    Thread Starter simplexunlocked

    (@simplexunlocked)

    Could perhaps explain which values are to be edited ^^;;; sorry this is a bit more advanced than what I’m used to. I’m not 100% fluent on php… yet….

    First of all, did you try the code? If you did, what is it that you would want changed?

    Thread Starter simplexunlocked

    (@simplexunlocked)

    okay i used it and for some reason it repeates the pull. for example, it pulls all my users posts and posts all the posts the same number of times as there are users. i just want it to pull the most recent post from the users and post them once, and preferably on a way that i can controll what apears where on the page with divs and such.

    I just put that code before the loop using the WordPress Default theme’s wp-content/themes/default/index.php and it listed one post for each user.

    Thread Starter simplexunlocked

    (@simplexunlocked)

    Okay with the plugin I’m using to run my comic it calls for an altered loop to ignore a certain category, would this alter the results of that code?

    Possibly. Switch to the WordPress Default theme, put that code just before the Put that code in the <?php if (have_posts()) : ?> in the wp-content/themes/default/index.php to see how it works.

    Thread Starter simplexunlocked

    (@simplexunlocked)

    Okay it seems to work right there, but i can’t seem to get it working right in the loop where i need it. Also there isn’t much to do to dictate what goes where. There isn’t amy specific tag i could use to pull a certain author?

    There isn’t amy specific tag i could use to pull a certain author?

    Not that I know of.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Pulling post by author’ is closed to new replies.