total number of listings – display total count

This topic contains 2 replies, has 2 voices, and was last updated by  step8601 9 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket

Tagged: 

  • Author
    Posts
  • #68542

    step8601
    Expired Member
    Post count: 215

    i know that categories can display how many listings are within a category, but is there a separate short code maybe that can display the total number of listings?

    i’m thinking that i might want to have a top-of-page horizontal notification bar that says something like, “We have X total listings on our site”

    i also might want to turn off the category counts but still display the total count

    i didn’t see anything in the demo or in my install or settings, sorry if i missed it

    thanks

    #68829

    Paolo
    Site Admin
    Post count: 31211

    Hi,

    there is no widget to do something like that.

    This snippet in your header.php file will output the total number of published listings:

    
    
    <?php $args = array(
    'public'   => true,
    '_builtin' => false
    );
    $output = 'names'; // names or objects, note names is the default
    $operator = 'and'; // 'and' or 'or'
    $post_types = get_post_types( $args, $output, $operator ); 
    foreach ( $post_types  as $post_type ) {
       $count_posts = wp_count_posts($post_type);
       $published_posts = $published_posts+$count_posts->publish;
    }
    echo 'We have '.$published_posts.' total listings on our site';
    ?>

    Let us know if this helped.

    Thanks

    #68934

    step8601
    Expired Member
    Post count: 215

    wow, thanks, will test this once my theme is made geodir compliant and get back to you, thanks again

Viewing 3 posts - 1 through 3 (of 3 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount