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

How can I change the date format of the revision list?

You can filter the output like bellow: <?php /** * @param $revision_date_author * @param $revision * @param $link * @return mixed */ function filter_wp_post_revision_title_expanded( $revision_date_author, $revision, $link ) { $revision = get_post( $revision ); if ( ! $revision ) { return $revision; } if ( ! in_array( $revision->post_type, array( ‘post’, ‘page’, ‘revision’ ), true ) … 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

Show single post child category from a determined parent

Well in the end I used custom taxonomy, and it’s also more simple to manage. I post as I did : //hook into the init action and call create_topics_nonhierarchical_taxonomy when it fires add_action( ‘init’, ‘create_regions_nonhierarchical_taxonomy’, 0 ); function create_regions_nonhierarchical_taxonomy() { // Labels part for the GUI $labels = array( ‘name’ => _x( ‘Regions’, ‘Where are … Read more