<?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_ID(); ?>"><?php the_title(); ?></h1> <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?> <?php link_pages('<p><strong>Pages:</strong> ', '</p>', 'number'); ?> <? $posts = get_posts('numberposts=50&category=1'); if($posts) : ?> <table border="0" cellpadding="5" cellspacing="0" width="100%"> <tr style="background:#cde; font-size:12pt; font-weight:bold"> <td width="40%">Description</td> <td width="20%">Location</td> <td width="20%">Revenue</td> <td width="20%">Earnings</td> </tr> <? $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); ?> <tr<? if($i % 2) { echo ' style="background:#def"'; } ?>> <td><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></td> <td><?php $loc = get_post_custom_values('location'); echo $loc[0]; ?></td> <td><?php $rev = get_post_custom_values('revenue'); if($rev) { echo $rev[0]; } else { echo ' '; } ?></td> <td><?php $adj = get_post_custom_values('adj_earn'); if($adj) { echo $adj[0]; } else { echo ' '; } ?></td> </tr> <? $i++; endforeach; endif; ?> </table><br /> <? endif; ?> <?php endwhile; endif; ?> </div> <?php get_footer(); ?>
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
WordPress custom post listing (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Wordpress clean URLS with Li... in lighttpd wordpress rewrite
» Ruby script to post daily de... in ruby wordpress rubilicious xmlrpc del.icio.us
» Display In 2-Column Table in php wordpress expressionengine movabletype
» Export WordPress tables in mysql wordpress mysqldump
» Customizing flickrRSS in wordpress
» Scrobbler in wordpress
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails