WordPress.org

Ready to get started?Download WordPress

Forums

Post Word Count - how to exclude pages, only count words in Posts not Pages? (2 posts)

  1. Dgold
    Member
    Posted 5 years ago #

    Can anyone tell if this plugin counts the total # of words in Posts & Pages, or Just Posts?

    I want to count just the posts.

    http://wordpress.org/extend/plugins/post-word-count/

    the relevant part of the plugin code may be this,

    if ($single) $query = "SELECT post_content FROM $wpdb->posts WHERE ID = '$id'";
    	else $query = "SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now'";

    How to exclude Pages from it?

  2. tomontoast
    Member
    Posted 5 years ago #

    It was counting the total # of words in Posts & Pages. The following modification excludes pages:

    if ($single) $query = "SELECT post_content FROM $wpdb->posts WHERE ID = '$id' AND post_type='post'";
    	else $query = "SELECT post_content FROM $wpdb->posts WHERE post_status = 'publish' AND post_date < '$now' AND post_type='post'";

Topic Closed

This topic has been closed to new replies.

About this Topic