Modify main loop query for paged and meta key

I think this will do what you want. But I still wonder whether sticky posts wouldn’t have been better… if (is_home() && $paged == ‘0’) { //$paged value is 0 on 1st page and not 1 ! query_posts(‘posts_per_page=7&paged=’.$paged.’&meta_key=_pull_leading3&meta_value=off’); } else { // recreate the home page “loop” to figure out which posts to exclude $excluded … Read more

Exclude posts without category from loop

Hi @Raffaele: The function wp_get_object_terms(…) can provide you with the information you need. I’ve written a has_category($post_id) function that can be used in the loop like this: <?php while ( have_posts() ) : the_post(); ?> <?php if (has_category($post->ID)): ?> <p><?php the_title(); ?></p> <?php endif; ?> <?php endwhile; ?> And here is the has_category() function: <?php … Read more

Filter or order based on custom field

I have added a custom field to some posts called ‘frontpagerank’ Then shouldn’t the WP_Query args reference that key then, eg. ‘meta_key’ => ‘frontpagerank’ If i follow, you want to check for posts that have this key, and you’re expecting a numeric value, so i’ll naturally assume you don’t want posts with this key(but an … Read more

WordPress: query pages except remove one page

Update: You must use exclude the page using post__not_in paremeter. Rewrite your query using the array parameters query_posts(array( ‘post__not_in’=>array(‘271’), ‘post_parent’=>6, ‘post_type’=>’page’ ) ); See this page for reference.

get post images to link to external sources

http://codex.wordpress.org/Function_Reference/get_post_meta wouldn’t echoing get_post+meta in the a link be best? <a href=”https://wordpress.stackexchange.com/questions/12095/<?php echo get_post_meta($post->ID,”externalurl”, true) ); ?>” rel=…and so on

“Order” doesn’t work in custom loop?

Add orderby clause to your query! Here is the complete list of order parameters $loop = new WP_Query( array( ‘post_type’ => ‘images’, ‘orderby’ => ‘menu_order’, ‘paged’ => get_query_var(‘paged’) ? get_query_var(‘paged’) : 1, ‘posts_per_page’ => $per_page, ) ); This query order by the menu order that you have specified in your pages