• Hello all-
    I’m trying to do a query where only the admins posts are shown.
    My ultimate goal is to have the admins post shown in its own loop and all other authors shown in another on the same page.
    But first things first. I can’t get the query/loop to show just the admins posts.
    Here’s what I have:

    <?php if (have_posts()) : ?>
    
    <?php query_posts('author=1&numberposts=4'); ?>
    
    <?php while (have_posts()) : the_post(); ?>
    <div class="post" id="post-<?php the_ID(); ?>">
    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> <small>Viewed <?php the_view_count(); ?> Times</small>
    <span id="l_writtenby">by <span id="l_author"><?php the_author(); ?></span></span>
    <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
    
    <div class="entry">
    <?php the_content('Read the rest of this entry &raquo;'); ?>
    </div>
    
    <p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?>
    </div>
    
    <?php endwhile; ?>
    
    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Previous Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Next Entries &raquo;') ?></div>
    </div>
    
    <?php else : ?>
    
    <h2 class="center">Not Found</h2>
    <p class="center">Sorry, but you are looking for something that isn't here.
    
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>
    
    <?php endif; ?>

    Any Suggestions are greatly appreciated
    Thanks
    -Landon

Viewing 8 replies - 1 through 8 (of 8 total)
  • Did you try:

    <?php query_posts($query_string.”&author=1″); ?>

    Thread Starter lacohido

    (@lacohido)

    Hella-
    Still nothing… Is it where I’m putting the query?
    Thanks
    -Landon

    Not sure, sorry. Definitely needs to be outside The Loop but you already have it there.

    I’m not sure why you are trying to do this so this might work for you or not. I have a family site and wanted people to see a couple of the authors individually on the side so I used a simple text widget with index.php?author=1 (1 being the number of an author) to display the individual author. Very easy and separates an author out and I don’t have to mess with the loop.

    Moderator Samuel Wood (Otto)

    (@otto42)

    www.remarpro.com Admin

    Well, ideally, query_posts should be before the if (have_posts()) line, but I can’t see that it would make any difference in such a case.

    Go look at the Users page, make sure that the admin is user number 1. Can’t think of why he would not be, but hey, it’s possible.

    Passing author=1 to query_posts should indeed work.

    Thread Starter lacohido

    (@lacohido)

    Thanks Everyone-
    I’ll mess with it some more and let you guys know my results

    Thread Starter lacohido

    (@lacohido)

    Weird Thing-
    I tried the query Hella proposed on a different WordPress site I’m running and it worked fine (It displayed only the author that I specified). Very weird. they are both running 2.3.3
    Any Suggestions
    -Landon

    Thread Starter lacohido

    (@lacohido)

    Could it Be???-
    I transferred the wordpress to another webhost and the “author” query worked like a charm. Could it be that MySql is set up different on the webbhosts? I transferred from Ixwebhosting to MediaTemple DV.
    Thanks
    -Landon

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Query Question. How to show posts from specific author’ is closed to new replies.