Displaying page image in the footer automatically

You want to use the Featured Post Thumbnail: http://wpcanyon.com/tutorials/how-to-use-the-post-thumbnail-feature-in-wordpress-2-9/ http://markjaquith.wordpress.com/2009/12/23/new-in-wordpress-2-9-post-thumbnail-images/ http://codex.wordpress.org/Function_Reference/the_post_thumbnail In your functions.php, define an image size with add_image_size(), then display it in the footer like this: the_post_thumbnail(‘footer-image’); Keep all of the loop inside of your main template file and do not split it across multiple files. That’s really messy, and as you’ve figured … Read more

Include multiple page ids in loop

page is not an accepted parameter for WP_query , you can use page_id but that doesn’t accept an array , only one specific ID, so just use post__in like this: <?php $args = array( ‘post__in’ => array(139, 54) ); $loopy = new WP_Query($args); while ($loopy->have_posts()) : $loopy->the_post(); ?> <div class=”item”><?php the_title(); echo ‘<br ?>’; echo … Read more

Recent posts per category loop?

here is a quick one: (edit: I updated some forgotten punctuation). <?php /* Plugin Name: Recent posts per category loop Plugin URI: http://en.bainternet.info Description: answer to http://wordpress.stackexchange.com/questions/16616/recent-posts-per-category-loop Author: Bainternet Version: 1.0 Author URI: http://en.bainternet.info */ // Initialization function function WP_Widget_display_widget_init() { new WP_Widget_display_widget(); } // Your Class class WP_Widget_display_widget extends WP_Widget { // Constructor function … Read more

Stepping through a foreach loop – adding +1 to the end of it so next time it loops it starts on item 2

Use the offset argument, and only get 1 result: global $my_page_offset; if(!isset($my_page_offset)) $my_page_offset = 0; $pages = get_pages(array( ‘child_of’ => $post->ID, ‘sort_column’ => ‘menu_order’, ‘offset’ => $my_page_offset, ‘number’ => 1, )); $my_page_offset++; … I’m assuming here that you don’t have much control over these loops, because you’re doing them multiple times. This is why the … Read more

Filter Loop by Custom Field Value

How about this: $my_query = new WP_Query(array( ‘post_type’=> ‘custom_type’, ‘post_status’ => ‘publish’, ‘meta_key’ => ‘my_custom_field’, ‘meta_value’ => ‘custom field value’ )); if($my_query->have_posts()): while($my_query->have_posts()):$my_query->the_post(); //All the post stuff here. endwhile; endif; wp_reset_postdata(); Check this out.

Add class to last 3 posts in loop

WP_Query seems to set two variables, $posts and $post_count when running(according to the source over at http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/query.php ). You can access these two and work something out to figure out if you’re in the last three posts. var_dump those two to see if there’s a count, add in your own counter and you should be … Read more

Group posts by date with a list

I usually perform a simple check to see if that day has changed. <?php $day_check = ”; while (have_posts()) : the_post(); $day = get_the_date(‘j’); if ($day != $day_check) { if ($day_check != ”) { echo ‘</ul>’; // close the list here } echo get_the_date() . ‘<ul>’; } ?> <li><a href=”#”><?php the_time(); ?><?php the_title(); ?></a></li> <?php … Read more