Adding count also to parent categories

You could add this to your code: function custom_add_count_on_archive_title( $title ) { $term = get_queried_object(); $term_id = get_queried_object()->term_id; if( $term instanceof WP_Term && ‘category’ === $term->taxonomy ) { $children_terms = get_terms(array( ‘taxonomy’ => ‘category’, ‘child_of’ => $term_id, )); $total_count = 0; if (!empty($children_terms) && !is_wp_error($children_terms)) { foreach ($children_terms as $child_term) { $total_count += $child_term->count; } … Read more

Hide load more button if no more post in selected category

I believe you should pass one more label “How many posts remain to be seen” in your $response array in function filterPosts() You know the total number of posts based WP_Query that exist in the database $filter_query = new WP_Query($filter_args); $total_query_posts = $filter_query->found_posts; So, then you have to calculate it based on paged and posts_per_page, … Read more

How to get total posts count for each date?

Instead of the second loop, do the following: Count the posts per date Display them as you will // Count the posts per date $count = []; foreach ( $posts as $post ) { $date = get_the_date( ‘Y-n-j’, $post ); $count[ $date ] = ! isset( $count[ $date ] ) ? 1 : $count[ $date … Read more

Adding a posts count in archive pages

If the theme your’re using doesn’t do anything fancy, but uses the_archive_title() to render the “Lignano Sabbiadoro”, then you should be able to modify it with the get_the_archive_title filter. Something along these lines. add_filter(‘get_the_archive_title’, ‘my_get_the_archive_title_filter’, 10, 3); function my_get_the_archive_title_filter(string $title, string $original_title, string $prefix): string { if (! is_category()) { return $title; } $current_category = … Read more

Can I count every article following extracted meta value?

Use array_count_values() (untested): <?php $posts = get_posts( array( ‘numberposts’ => -1, ‘category_name’ => ‘bird’, ‘order’ => ‘ASC’, ) ); if ( $posts ) { foreach( $posts as $post ) { $species[] = get_post_meta( $post->ID, ‘species1’, true ); $species[] = get_post_meta( $post->ID, ‘species2’, true ); } } $species = array_filter( $species ); $counts = array_count_values( $species … Read more

Count the number of matching post names in foreach loop

I would get the count of a variable number of repeated titles by using an indexed array. $theposts = get_posts( array( ‘post_type’ => ‘post_subscriber’, ‘post_status’ => ‘publish’, ‘numberposts’ => -1, ) ); // project titles counter, outside the loop $project_titles = array(); foreach( $theposts as $p ): $project_name = get_post_meta($p->ID, ‘project’, true); echo ‘<ol>’; echo … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş