Set post title font size automatically according to number of words in post title

You need to target the the_title filter. In that filter we can manipulate the output string as we need. add_filter(‘the_title’, ‘bt_the_title’); function bt_the_title ($title) { if (current_user_can(‘administrator’)) { if (strlen($title) > 15) { $title=”<span class=”font18px”>” . $title . ‘</span>’; $title=”<span style=”font-size: 18px”>” . $title . ‘</span>’; } } return $title; } add the code in … Read more

Author post count in category

You don’t need to loop through the posts for this. Instead, just call the method get_posts() which will return an array of posts and then just count the number of posts in that array. $user_id = get_the_author_meta(‘ID’); $args = array( ‘author_name’ => $user_id, ‘category_name’ => ‘categoryname’, ); $wp_query = new WP_Query($args); $posts = $wp_query->get_posts(); $my_count … Read more

display post count in archive page that have relation with another taxonomy term

SOLUTION <?php $args = array( ‘post_type’ => ‘product’, ‘post_status’=>’publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘sectors’, ‘field’ => ‘slug’, ‘terms’ => ‘garden’, ), array( ‘taxonomy’ => ‘season’, ‘field’ => ‘slug’, ‘terms’ => ‘winter’, ), ), ); $query = new WP_Query( $args ); echo $query->post_count ; ?>

ACF: How to query for a given value count of an array like field? (e.g.: How many rows has a `flexible_content` field?)

This isn’t possible using WP_Query, you can’t query the insides of structured data stored in a single post meta value. At best you can use regular expressions, or do math/boolean comparisons, you can even do LIKE comparisons, but these are all string operations. If you need to query structured data such as objects or arrays, … Read more

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