• Resolved Pete

    (@perthmetro)


    I have this conditional snippet that counts if the current user has published any normal posts. How would this be updated to count if the current user has published any custom posts?

    <?php if ( 0 == count_user_posts( get_current_user_id() ) && is_user_logged_in() ) { ?>
    do something
    <?php } else { ?>
    do something else
    <?php endif; ?>

    Thanks,
    Pete

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    count_user_posts() has an optional second argument for post type that defaults to ‘post’. Merely supply your post type as an argument.
    count_user_posts( get_current_user_id(), 'my_post_type' )

    Thread Starter Pete

    (@perthmetro)

    I just figured it out before you posted this … By myself ?? thanks for your help as well. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to count_user_posts for custom post type’ is closed to new replies.