Here is code , basically I want to fetch by Post author but not able to solve this any help regards this .
<?php
global $post;
$author = get_the_author();
$args = array(
'author' =>$user_ID,
'posts_per_page' => $per_page,
'author'=> $author,
'post_type' => 'ultimate-auction',
//'auction-status' => 'expired',
'post_status' => 'publish',
'offset' => $pagination,
'orderby' => 'meta_value',
'meta_key' => 'wdm_listing_ends',
'order' => 'DESC',
);
$author_posts = new WP_Query( $args );
if( $author_posts->have_posts() ) {
while( $author_posts->have_posts()) {
$author_posts->the_post();
?>
<?php the_content();?></div>
<?php
// you should have access to any of the tags you normally
// can use in The Loop
}
wp_reset_postdata();
}
?>
Here is code , basically I want to fetch by Post author but not able to solve this any help regards this .
<?php
global $post;
$author = get_the_author();
$args = array(
'author' =>$user_ID,
'posts_per_page' => $per_page,
'author'=> $author,
'post_type' => 'ultimate-auction',
//'auction-status' => 'expired',
'post_status' => 'publish',
'offset' => $pagination,
'orderby' => 'meta_value',
'meta_key' => 'wdm_listing_ends',
'order' => 'DESC',
);
$author_posts = new WP_Query( $args );
if( $author_posts->have_posts() ) {
while( $author_posts->have_posts()) {
$author_posts->the_post();
?>
<?php the_content();?></div>
<?php
// you should have access to any of the tags you normally
// can use in The Loop
}
wp_reset_postdata();
}
?>
You are using 'author' => ...
twice in your code.
To get the author's ID, you should use get_the_author_meta('ID')
instead. So, remove the second author argument, and use this in your code:
$author = get_the_author_meta('ID');
$args = array(
'posts_per_page' => $per_page,
'author'=> $author,
'post_type' => 'ultimate-auction',
//'auction-status' => 'expired',
'post_status' => 'publish',
'offset' => $pagination,
'orderby' => 'meta_value',
'meta_key' => 'wdm_listing_ends',
'order' => 'DESC',
);
By the way, the global $post
itself contains the ID of post's author, which you can get it by using $post->post_author;
.
If you want to use the author's name, you can use 'author_name' => ...
together with get_the_author_meta('nicename')
.
Take a look at author parameters of WP_Query
in the WordPress codex for more details.
$args = array(
'author' => $current_user->ID,
'orderby' => 'post_date',
'order' => 'ASC',
'posts_per_page' => 1
);