0

I am writing a plugin for my company so I need to get all posts belongs to a user between a certain date which is given by another user.

Then I want to count words for each post and finally add them up to a variable and save that value to the database.

There are two main questions:

1- How to get all posts belongs to a user between a certain date?
2- How to get word count for each post?

thanks.

2

Check out the WP_Query reference.

For parameters.

Date Parameters.

$args = array(
    'author' => 123 ,
    'date_query' => array(
        array(
            'after'     => 'January 1st, 2013',
            'before'    => array(
                'year'  => 2013,
                'month' => 2,
                'day'   => 28,
            ),
            'inclusive' => true,
        ),
    ),
    'posts_per_page' => -1,
);
$query = new WP_Query( $args );

For the word count check out this post. It has a quick way of doing it by using explode get the post content and then using explode and count.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.