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

How to show the amount of post that have on the site?

Using a query could give you easier customization without having to use SQL directly. $posts = get_posts( array( ‘post_type’ => ‘post’, ‘post_status’ => ‘any’, ‘numberposts’ => -1, ‘fields’ => ‘ids’, )); $total_count = count( $posts ); print_r ( $total_count );

How make animation increase of number

i make this: $(window).scroll(function() { var currentNumber = $(‘.js-number-lifetime’).text(), targetNumber = $(‘.js-number-lifetime’).attr(‘data-target’); $({numberValue: currentNumber}).animate({numberValue: targetNumber}, { duration: 1000, easing: ‘linear’, step: function() { $(‘.js-number-lifetime’).text(Math.ceil(this.numberValue)); } }); var currentNumber1 = $(‘.js-number-clients’).text(), targetNumber1 = $(‘.js-number-clients’).attr(‘data-target’); $({numberValue: currentNumber1}).animate({numberValue: targetNumber1}, { duration: 1000, easing: ‘linear’, step: function() { $(‘.js-number-clients’).text(Math.ceil(this.numberValue)); } }); var currentNumber2 = $(‘.js-number-employee’).text(), targetNumber2 = $(‘.js-number-employee’).attr(‘data-target’); $({numberValue: … Read more

How to calculate posts number? [closed]

Do you mean like this $result = 10; foreach ( $posts as $post ) { if ( $a = $b ) ) { $result += 1; } else { $result -= 2; } } echo ‘Your result is ‘ . $result; This is the best I can do with the provided information

get the count of table rows

I think that’s you must using : $wpdb->get_results( “SELECT * FROM {$wpdb->prefix}options WHERE option_id = 1”, OBJECT ); And if you give us the message of error ?

CountPost WordPress Custom Taxonomy

I do not know exactly what you mean, but I think you need something like this? $categories = get_terms( array( ‘taxonomy’ => ‘category’ ) ); if ( $categories ) { $output=””; foreach( $categories as $category ) { $output .= ‘<li title=”‘ . __( ‘View all’, ‘themename’ ) . ‘ ‘ . $category->count . ‘ ‘ … Read more

$count_posts->draft & published

In this line you are getting only the count of published items (obviously!!!!): $published_projects = $count_projects->publish; You should do something like this: $count_projects = wp_count_posts( ‘apps’ ); $published_projects = $count_projects->publish; $draft_projects = $count_projects->draft; $total = $published_projects + $draft_projects; More details and examples in wp_count_posts() reference.

How to read out the excerpt length (for if-condition)

This is more PHP as you need to use str_word_count() to count the amount of words in the excerpt. Just note, to be safe, if you allow any tags in the excerpt, you would want to use strip_tags() to remove html tags to avoid incorrect word counts. EXAMPLE: echo str_word_count( strip_tags( get_the_excerpt() ) ); If … Read more

Search Count WordPress Theme

If you are in the search results template then you can find out the count by using the below code. global $wp_query; $count = $wp_query->found_posts variable $count contains the count of post against the search.