• How a best WordPress language plugin!

    Currently, I want to show my custom post type number in somewhere with short code and just count current language CPTs.
    * plugin name and post type name: Enfold / portfolio.
    I following some post solution and write below code but not effective.

    function wpb_total_posts() {
    $total = pll_count_posts( pll_current_language('portfolio') );
    return $total;
    }
    add_shortcode('total_posts','wpb_total_posts');

    Hope someone can help ??

    • This topic was modified 4 years, 4 months ago by j232029.
Viewing 1 replies (of 1 total)
  • eminozlem

    (@eminozlem)

    function wpb_total_posts() {
    $total = pll_count_posts( pll_current_language(),array(‘post_type’=>’portfolio’) );
    return $total;
    }
    add_shortcode(‘total_posts’,’wpb_total_posts’);

Viewing 1 replies (of 1 total)
  • The topic ‘Count custom post type’ is closed to new replies.