How to count get_users query?

when you use get_users() it retrieves an array of users matching the criteria given in $args which means you can simply use PHP’s count() function e.g: $users = get_users($args); $number_of_users = count($users);

Number of items in a menu

I was curious and decided to check it out, regardless if it’s relevant for a CSS problem 😉 I first peeked into the database tables to find more about the menu structure: Menu – building blocks Each navigational menu is registered as a term in the nav_menu taxonomy. Then when we add items to that … Read more

Get count of custom post type created by current user

I’m posting a new answer because I found this thread while searching for the same thing and the solutions here weren’t optimal. The post_type argument can be a string or an array of post types. function custom_count_posts_by_author($user_id, $post_type = array(‘post’, ‘page’, ‘custom_post_type’)) { $args = array( ‘post_type’ => $post_type, ‘author’ => $user_id, ‘post_status’ => ‘publish’, … Read more

Alternate custom content in the loop

You could initialize a second counter variable that increments when your first counter variable increments, and use that with modulus to alternate your code blocks. First initialize two counter variables: <?php if (have_posts()) : $show_alternate = 1; $which_alternate = 1; while (have_posts()) : the_post(); ?> Then in your .pin-alternate-content output code you could do something … Read more

How to change post count in wordpress loop?

First, go to Settings->Reading->Blog pages show at most->25. Or change the posts_per_page in main query to 25. Then, try this code in your template: if (have_posts()) : $count = 0; $paged = ( get_query_var(‘paged’) > 1 ) ? get_query_var(‘paged’) : 1; while (have_posts()) : the_post(); $count++; if ($count <= 3 && $paged === 1) : … Read more

Count posts for each year

The Easy Way This is by far and away the easiest approach to this, but unless you are willing to be a little bit flexible with how you present your archive it’s not for you. The easy solution is achieved using the wp_get_archives() function. Unfortunately though there is no filter available to manipulate the output, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)