WP Query $CurAuth
-
Hi all, trying to get posts of a custom post type for the current author – and order by custom meta. Unfortunately query below seems to pull the same posts for every author and simply change the author id/nicename – not sure what i’m missing here or why the $arg for the author isn’t working.
anyone have a pointer?
<!– This sets the $curauth variable –> <?php $curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); ?> <p>This is <?php echo $curauth->nickname; ?>'s page</p> <!– The Query–> <?php $args = array( 'author' => '$curauth->ID', 'post_type' => 'competitor', 'meta_key' => 'average', 'orderby' => 'meta_value_num', 'showposts' => 10, ); $the_query = new WP_Query( $args ); ?> <!– The Loop –> <?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?> <?php $average = get_post_meta(get_the_ID(), 'average', true); // check if the custom field has a value if($average != '') { echo ($average)." <br />"; } ?> <?php endwhile; ?> <!– End Loop –>
- The topic ‘WP Query $CurAuth’ is closed to new replies.