Get queried object for custom post type count

function wpse340250_term_count( WP_Term $term, $post_type) { $q_args = [ ‘post_type’ => $post_type, ‘nopaging’ => true, // no limit, pagination ‘fields’ => ‘ids’, // only return post id’s instead of full WP_Post objects will speed up ‘tax_query’ => array( array( ‘taxonomy’ => $term->taxonomy, ‘field’ => ‘term_id’, ‘terms’ => $term->term_id, ), ), ]; $term_count = get_posts($q_args); return … Read more

Count time from registration date to today

Just gave an example of how to do it: $today_date = new DateTime( date( ‘Y-m-d’, strtotime( ‘today’ ) ) ); $register_date = get_the_author_meta( ‘user_registered’, get_current_user_id() ); $registered = new DateTime( date( ‘Y-m-d’, strtotime( $register_date ) ) ); $interval_date = $today_date->diff( $registered ); if( $interval_date->days < 31 ) { echo ‘With us ‘ . $interval_date->format(‘%d days’); … Read more

How to count items of meta query?

$query->found_posts may be what you are looking for from the code reference: https://developer.wordpress.org/reference/classes/wp_query/ Note that meta_query expects nested arrays, even if you only have one query. You may need to use: $meta_query[0][] = array( ….. You should also take care with the form of the original query. If there are one or more relations defined, … Read more

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