Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

nblauw on "How-to use a shortcode in a page or post title"

$
0
0

Hello!

I want to use different shortcodes in a page or posttitle

Total comment count;

function comment_count() {
  global $wpdb;
  return $wpdb->get_var("SELECT COUNT(*)
                         FROM $wpdb->comments
                         WHERE comment_approved = 1");
}

add_shortcode('commentcount', 'comment_count');

And Total post count;

function post_count() {
  global $wpdb;
  return $wpdb->get_var("SELECT count(id)
                         FROM $wpdb->posts
                         WHERE post_type = 'post'
                         AND post_status = 'publish'");
}

add_shortcode('postcount', 'post_count');

I know I need do something with filters? Can somebody help me with this question?


Viewing all articles
Browse latest Browse all 8245

Trending Articles