• Resolved Reobed

    (@reobed)


    Hello Greg, need some advice.
    I would like to display the total number of ads on my site.
    Like : Total Ads : xxxxx
    Simple as that

    If I need a function in the them created I kind of need something like :

    function wpb_total_posts() {
    $total = wp_count_posts()->publish;
    return $total;
    }
    add_shortcode(‘total_posts’,’wpb_total_posts’);

    But I assume that the adds section has their own “prefix” and tables.
    Could you tell me what prefix(names) I have to use.

    something like below I assume…?
    function <wpad_total_posts() {
    $total = wpad_count_posts()->publish;
    return $total;
    }
    add_shortcode(‘total_posts’,’wpad_total_posts’);

    Thanks

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    by default the wp_count_posts() function counts the blog posts, if you want to count published Adverts then you should use it like this

    
    function wpb_total_posts() {
        return wp_count_posts( 'advert' )->publish;
    }
    add_shortcode( 'total_posts', 'wpb_total_posts' );
    
    Thread Starter Reobed

    (@reobed)

    Works Perfectly . Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Counting total number of add ans display on site’ is closed to new replies.