WordPress.org

Ready to get started?Download WordPress

Forums

author posts outside the loop (2 posts)

  1. zandercent
    Member
    Posted 3 years ago #

    Hi I'm using the current code to retreive all the posts of the current page's author, and skip the current post id, which is 159

    <?php query_posts("author", $theauthorid);
    while (have_posts()) : the_post(); if( $post->ID == '159' ) continue; ?>

    basically I need to skip the current post - so how would I do that automatically? ie replace the 159 in the code above with whatever the current post id is?

    thanks,

  2. zandercent
    Member
    Posted 3 years ago #

    got it

    <?php
    
      //Gets author info and current post id
      global $wp_query;
      $postAuthor = $wp_query->post->post_author;
    $tempQuery = $wp_query;
      $currentId = $post->ID;
    
    query_posts("author=$postAuthor");
    
    while (have_posts()) : the_post(); if( $post->ID == $currentId ) continue; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic