BuddyDev

Search

buddyblog display posts and custom post type at the same time

Tagged: 

  • Participant
    Level: Initiated
    Posts: 10
    richard gueron on #761

    I try this but no luck

    $count = $wpdb->get_var( $wpdb->prepare( “SELECT count(‘*’) FROM {$wpdb->posts} WHERE post_author=%d AND (post_status=’publish’||post_status=’draft’||post_type =’Concours’)”, $user_id ) );

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #764

    Hi Richard,
    What is the post type name. ‘Concours’ is the label of that post type( seems to me as WordPress recommends using lower cases for the name )

    Also, If I understand it correctly, you want it for ‘post’ as well as ‘Concours’ both. Is that right?

  • Participant
    Level: Initiated
    Posts: 10
    richard gueron on #774

    Hello Brajesh, yes i want to have a total count of both posts and concours’posts from a user

  • Keymaster
    (BuddyDev Team)
    Posts: 24149
    Brajesh Singh on #779

    Hi Richard,
    Apologies for the delayed reply.
    here is the code

    
    
    $count = $wpdb->get_var( $wpdb->prepare( "SELECT count('*') FROM {$wpdb->posts} WHERE post_author=%d AND ( post_type = 'post' || post_type ='concours' ) AND post_status='publish'", $user_id ) );
    
    

    Hope that helps.

  • Participant
    Level: Initiated
    Posts: 10
    richard gueron on #932

    Sorry for delay.

    It’s perfect thank you!

You must be logged in to reply to this topic.

This topic is: not resolved