Articles of count

2 queries with counters

I have 2 loops on a page both containing a counter to implement slightly different code every 6 posts. For some reason though the second loop is implementing the different code sometimes after 4 items instead of 6. Am I not resetting the loop correctly? <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> […]

Change categories count to include media attachments

I am creating a gallery that will automatically display new images from a chosen category and its subcategories. I have set up the categories so that they will apply to media using: register_taxonomy_for_object_type( ‘category’, ‘attachment’ ); Now I need to make it so that categories will count the related attachments not just posts. I found […]

Count search results in heading

On my wordpress search page I would like to show a ‘total found results’. This needs to be shown at the top of the page in a heading. I’ve tried this code but I gives me only the results of the specific page. What I want is all the results, not just the page. <?php […]

How to use global post counter in the loop?

In the Loop use this code <?php $count = $wp_query->current_post; echo $count; ?> On first page post counts from 0 to 14, but from second page post counts from 0 to 14 to. How use global counter for count post on second from 15 to 29, third from 30 to 44 …

How can I count only guests comments?

I need to ignore counting author replies within comments number function, for example If I have 9 replies (comments) which 4 of them appertain to post author, I would display 5 comments as comments number in my post. Do you know any method to do it? Thanks in advance.

Post Views / Hit Counter Problem?

I have decide to use WordPress as a CMS to my 5 moths old website. I have already added all previous posts to my new site ( WordPress ). But now I need to change view counts to previous views counts. I can’t find hit_count or views_count from PhpMyAdmin database. How to change views count […]

Add “showing posts x to x of y” in custom post type paginated loop

Is there a way that I can add “Showing posts x to x of y” into a paginated custom post type loop? So for example if I have 100 posts I’m showing 10 posts per page, on /page/3 it would show “Showing posts 21 – 30 of 100”.

(get_post_ancestors == 2) is returning true on 1 as well?

I am trying to use this code: <?php if(count(get_post_ancestors($post->ID)) == 2 ) : ?> <script>…</script> <?php endif ?> to add a script to a page but only if the page is a grandchild page (3rd level down, when it has 2 ancestors): Desired Result (with code above): Parent Page Child Page Grandchild Page (show script […]

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

I’m trying to do is the following. If the excerpt length is shorter than 30 charakters, than do.. <?php if ( get_the_excerpt() <= 30 AND has_post_thumbnail() ) : ?> <div></div> <?php else : ?> <div></div> <?php endif; ?> But it seems like that’s not the way to read out the length. I was playing around […]

WordPress Count posts within a custom post type

How to WordPress count post within this code. <?php query_posts(‘showposts=6’); ?> <?php $posts = get_posts(‘numberposts=6&offset=0’); foreach ($posts as $post) : start_wp(); ?> <?php static $count1 = 0; if ($count1 == “6”) { break; } else { ?> <div class=”col-md-4 com-xs-12 pannel”> <div class=”pannel-news”> <?php the_post_thumbnail(); ?> <div class=”sidebar-color”> <strong><a href=”<?php the_permalink(); ?>”><?php the_title( ‘<h4>’, ‘</h4>’ […]