Loop counter style

You can use the Modulo Operator in PHP to check if the loop count is odd or even and then assign those elements a CSS class based on that. $class=”listpostsright”; if ($wp_query->current_post % 2 == 0) { $class=”listpostsleft”; } Things to note: In programming counting begins at 0, so this logic may look a bit … Read more

PHP Warning: strip_tags() expects parameter 1 to be string?

If you look at the source of get_the_term_list, you will see that it will try to get the terms first. If that doesn’t succeed, it will return an error or false. So you would have to account for that before you try to strip the tags: if (!is_wp_error ($categories) && false != $categories) $categories = … Read more

Get the amount of posts on a current page

You can use the below to output the post amounts <?php $args = array( ‘post_type’ => ‘post’, ‘showposts’ => ’10’ ); $wp_query = new WP_Query($args); // amount of posts per on the page $post_number = $wp_query->post_count; // amount of posts across the post pages $post_number2 = $wp_query->found_posts; echo $post_number.'<br />’; echo $post_number2.'<br />’; while ( … Read more