Breaking Bootstrap Grid at Post Count with Tax Terms

I’m not exactly sure where you want your clearfix to come in, but you should be able to do something like this: <div class=”row”> <?php $libargs=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0, ‘exclude’ => array(16, 20, 22,25, 27, 28, 30, 4), //* Enter ID’s of parent categories to exclude from list ‘taxonomy’ … Read more

counting trackbacks, pingbacks and comments of a post

I think you can use get_comments. In the type parameter you can pass the type of comment (trackback, ping), you can filter by status, and you have a parameter called count, that when is set to true returns just the number of comments that match the parameters you passed. get_comments( array( ‘status’ => ‘approve’, ‘post_id’=> … Read more

How to exclude posts from category posts count

Assuming you have a list containing the post IDs you want to exclude, you could start with something like (PHP 7.3): function exclude_posts_from_category( array $cat_args ): array { $exclude = array(); // TODO Add post IDs to exclude. $cat_args[‘exclude’] = $exclude; return $cat_args; } add_filter( ‘widget_categories_args’, ‘exclude_posts_from_category’, 10, 1 ); You can read about the … Read more

Search result count not matching actual result

If you want to exclude certain posts, wouldn’t the conditional be: if ($value != ” && get_post_meta($post->ID, ‘value’, true) != ‘value_to_exclude’) Anyhow, you’re excluding AFTER you run the query. So $total_results will always be ‘wrong’. The better approach is to write sql for WP_Query that does the excluding for you. But you didn’t include the … Read more

2 queries with counters

On the advise of Robert and Pieter I rewrote the loops using WP_Query instead of query_posts. It works now. Thanks guys. Here’s the code: <ul class=”tabs”> <li class=”tab-link current” data-tab=”tab-1″>Most Popular</li> <li class=”tab-link” data-tab=”tab-2″>Recent</li> </ul> <div id=”tab-1″ class=”tab-content current”> <div class=”slider”> <div class=”slide”> <?php $count = 0; $query = new WP_Query( array( ‘meta_key’ => ‘post_views_count’, … Read more

Change categories count to include media attachments

You’ve probably solved this, but for anyone else that needs this: $wp_taxonomies[‘category’]->update_count_callback = ‘_update_generic_term_count’; This is significant in the case of attachments. Because an attachment is a type of post, the default _update_post_term_count() will be used. However, this may be undesirable, because this will only count attachments that are actually attached to another post (like … Read more

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

WordPress Count posts within a custom post type

It looks that this code is very old. Function wp_start() is deprecated since WordPress 1.5 (Documentation). But you wanted to know how it code is counting so: $posts = get_posts(‘numberposts=6&offset=0’); – get 6 posts foreach ($posts as $post) : – iterate over each post static $count1 = 0; – initializes $count1 variable $count1++; – increase … Read more

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