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 );

Having problems getting the number of plays in a WordPress Playlist from an audio file

The code requires at least PHP 5.3. Dreamweaver does not support that PHP version, so it reports unknown, newer syntax as errors. WordPress requires just version 5.2.4, but it recommends at least 5.4. My suggestion is to use always the latest stable version on the server, currently PHP 5.6. Your development setup should use exactly … Read more

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.

What is the best way to do this? [closed]

Let’s start with proper indenting your code: <select name=”select-city” onchange=”location = this.value;”> <option value=””>Select a post to read</option> <?php if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array(‘posts_per_page’ => ‘-1′,’author’ => $current_user->ID); $author_posts = new WP_Query($author_query); $numposts = count_user_posts( $user_id ); // <- you can’t use $count_user_posts also – it’s a function, not a … Read more