Friday, October 28, 2022
HomeWordPress DevelopmentRely phrases for all posts by all authors

Rely phrases for all posts by all authors


You will want a perform to get all of the revealed posts and rely the phrases.

perform wpse410818_count_published_words() {

    $posts = new WP_Query(array(
        'post_type' => array( 'publish' ),
        'post_status' => 'publish',
    ));
    
    $rely = 0; //Beginning phrases rely
    if ( $posts->have_posts() ) {
        whereas ( $posts->have_posts() ) {
            $posts->the_post();
            //Add to the phrase rely
            $rely += str_word_count(trim(strip_tags(strip_shortcodes(get_the_content()))));
        }
    }
    
    echo $rely;
}

This can question the database everytime it runs, therefor, you would possibly need to cache the end result and replace it when a brand new publish is revealed or an current publish is modified.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments