Display trimmed version of the_post()

First of all, never use query_posts, use WP_Query instead. To show 50 carachters of each one of the pages: <?php $args = array( ‘post_type’ => ‘page’, ‘post_parent’ => ‘6’, ‘order’=> ‘DESC’ ); $pages_returned = new WP_Query($args); while ( $pages_returned->have_posts()): $pages_returned->the_post(); ?> <div class=”page-excerpt”> <h1><?php the_title(); ?></h1> <?php the_excerpt(); ?> </div> <?php endwhile; ?> Now for … Read more

Filter post query to only show direct children of category

I assume that by “direct children of category” you mean “posts directly assigned to the category” and not “posts assigned to child categories of the category specified”. The answer is in the Codex: Display posts that have this category (not children of that category), using category id: $query = new WP_Query( ‘category__in=4’ ); http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters Second, … Read more

Easy way to write complex queries in wordpress

I wouldn’t say it’s “easy”, but any complex queries like the one you have that can’t be handled via the API, WP_Query, or its filters should use the wpdb class. global $wpdb; $rows = $wpdb->get_results( ” SELECT p1.meta_value as avg, p2.meta_value as total, p1.meta_value * p2.meta_value as product FROM $wpdb->postmeta as p1, $wpdb->postmeta as p2 … Read more

Why in this archive page that call query_posts() function show only the last 10 posts?

WordPress by default will only load 10 posts. That can be changed in the admin under Settings->Reading and then setting the amount beside “Blog pages show at most”. You can override that number in your custom queries a couple of ways but I would first recommend against the use of query_posts() ( take a read … Read more

query post limits

The third parameter for add_filter is the priority in which the filter is executed, the forth is the number of parameters the function in the second parameter uses. The wpcodex_filter_main_search_post_limits function has an if that checks uses a couple of wordpress function to establish where in your page you are executing the code, in this … Read more