• I am using this function in my function.php theme page.

    function bac_post_word_count(){
    global $post;
    //Variable: Additional characters which will be considered as a ‘word’
    $char_list = ”; /** MODIFY IF YOU LIKE. Add characters inside the single quotes. **/
    //$char_list = ‘0123456789’; /** If you want to count numbers as ‘words’ **/
    //$char_list = ‘&@’; /** If you want count certain symbols as ‘words’ **/
    echo str_word_count(strip_tags($post->post_content), 0, $char_list);

    }

    Then i add this to show where i want in single.php or index.php

    <?php if(function_exists(‘bac_post_word_count’)) { bac_post_word_count(); }?>

    But this just count the words not spaces, numeric, symbols etc….
    I want to count every type of characters, spaces, dots, commas, even everything please help me…

Viewing 2 replies - 1 through 2 (of 2 total)
  • Can’t you just use the PHP function strlen() instead of str_word_count()?

    You code would just be:

    function bac_post_word_count(){
    global $post;
    echo strlen(strip_tags($post->post_content));
    }

    Thread Starter Asif Mushtaq

    (@asifmushtaq38)

    hmm nice thanks allot i solved.. .:) thanks again.. ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Character Counter WordPress’ is closed to new replies.