WordPress custom post listing
// This pulls out posts from WordPress and displays them on a Page Template, along with some Custom Fields.
<?php /* Template Name: Offerings */ get_header(); ?> <div id="content" class="widecolumn"> <div id="copy"> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <h1 id="post-"><?php the_title(); ?>h1> Read the rest of this page »</p>'); ?> '<p><strong>Pages:strong> ', '</p>', 'number'); ?> $posts = get_posts('numberposts=50&category=1'); if($posts) : ?>
$i=0; foreach($posts as $post) : setup_postdata($post); $rev = get_post_custom_values('revenue'); $rev1 = trim($rev[0], "$"); $rev2 = str_replace(",", "", $rev1); $revs[] = preg_replace('/ (\w* ?)?\d*/i', '', $rev2); /* strips space+words+space+digits */ $post_ids[] = $post->ID; endforeach; $together = array_combine($post_ids, $revs); arsort($together); if($together) : foreach($together as $key => $value) : get_a_post($key); ?> Description Location Revenue Earnings > </a>td> </td> <td><?php $rev = get_post_custom_values('revenue'); if($rev) { echo $rev[0]; } else { echo ' '; } ?>td> </td> tr> $i++; endforeach; endif; ?> </table><br /> endif; ?> <?php endwhile; endif; ?> div>