Skip to content

Instantly share code, notes, and snippets.

@domosedov
Created March 20, 2020 11:28
Show Gist options
  • Save domosedov/fb6a37863703cea5450ee3666c1d51dc to your computer and use it in GitHub Desktop.
Save domosedov/fb6a37863703cea5450ee3666c1d51dc to your computer and use it in GitHub Desktop.
WP get custom post-type
$args = array(
'author' => get_current_user_id(),
'post_type' => 'YOUR_CUSTOMPOST_TYPE',
);
$author_posts = new WP_Query( $args );
if ($author_posts->have_posts()): while ($author_posts->have_posts()) : $author_posts->the_post();
//DISPLAY CONTENTS HERE
endwhile; endif;
wp_reset_postdata();
wp_reset_query();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment