Custom Query num_rows returns wrong amount

If you want the total count of all the published posts in a particular category you can try this. $all_posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘cat’ => 3 ) ); echo $all_posts->post_count; or $all_posts = new WP_Query( array( ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘category_name’ => ‘uncategorized’ ) ); echo … Read more

AJAX search posts and pages

The error seams to come from another source, not your query. You don’t use wp_options table. So maybe skipping $wpdb->show_errors(); $wpdb->print_error(); would make things even work. But probably there is an error somewhere else. To get an overview how to create AJAX search helper, you can check here: http://www.wpcodelab.com/archives/create-a-custom-ajax-search-for-wordpress

Order by title without taking into account ‘the’

If you’re using the plugin SEO Ultimate (it’s popular and I recommend using it), it has a component called Slug Optimizer that strips those types of words out of the post-slug, so if the post title is “The Dandy Warhols”, the slug would just be “dandy-warhols”. Perhaps just order by the post-slug?

Loop to fetch 3 post_thumbnail instances from 3 most recent custom post types named “portfolio”

Try this: <?php get_header(); ?> <div id=”content” class=”clearfix row”> <article id=”post-<?php the_ID(); ?>” <?php post_class(‘clearfix’); ?> role=”article”> <section id=”work” class=”row”> <div class=”span3″> <h3>Recent Work</h3> <p>Intro Lorem ipsum</p> </div> <?php $args = array( ‘post_type’ => ‘portfolio’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => 3 ); $query = new WP_Query( $args ); $porfolio_post_ids = array(); if ( $query->have_posts() ) … Read more