How to list Pages with custom fields in 2 columns in WordPress

Recently, I needed to list all subpages of a parent page.  I also needed to display custom fields below each subpage. And, on top of that, the list needed to be 2 columns.
I found a solution for simply listing the pages in 2 columns, but it did not suggest how to modify the code to include custom fields.
So, thanks to our coding hero Mark Kaplun who supplied the below code, although he admits it’s a “dirty hack”. The sort_column is so that MyPageOrder would work properly for this listing.
<?php
$args = array(
‘post_type’ => ‘page’,
‘numberposts’ => 40,
‘sort_column’ => ‘menu_order’,
‘child_of’ => 84 // any parent
);
$attachments = get_pages($args);
//print_r(“attachements:” . $attachements);
echo ‘<div style=”float: left; margin: 0 10px 0 0;”>’;
?>
<?php
for ($i =0; $i<count($attachments)/2; $i++) {
$post = $attachments[$i];
//    foreach ($attachments as $post)  { ?>
<a href=”<?php echo get_permalink($post->ID) ?>” rel=”bookmark”><?php…

You Might Also Like...

  • The Death of the Boring Blog Post – Easily Add Columns to Any WordPress Post

    331 readersEasily put your post's content into columns using just the WordPress text editor and a CSS grid.

  • Posts in two columns in WordPress

    Publishing WordPress posts in two columns

    389 readersWe’re currently building a site on Adii’s Premium Gazette WordPress theme (this is an affiliate link). In my opinion, it’s an awesome theme particularly because of the design. However, we installed it on the client’s server of choice, and the posts on the homepage just wouldn’t update. We tested ...

  • Display sticky post and exclude it from recent posts list in WordPress

    1587 readersWe were working on a WordPress site that needed to display a sticky post at the top of the blog page with one style, and then below it a list of the most recent posts with a completely different style. I realize that you can just style the sticky post using the sticky-related classes provided

  • Most Commented Posts The Right Way in WordPress

    1423 readersJust a very quick tip but nonetheless an important one. Many of you will be using any number of plugins or the database query that's been doing the rounds recently to display your most popular posts. That code/plugin is no longer needed as WordPress' query_posts can now display your most commented posts.You really should be

  • How to create an archive based on custom fields, not publish date in WordPress

    1912 readersWe recently launched a site called theforgottenletters.org, an incredible project dedicated to translating the Holocaust-era letters of Ralph Schwab from German to English. While building the site, we needed to archive the letters based on the dates the letters were written, not when we publish them to the site. First, I tried this tutorial: How

  • Jon Asked: How to add thumbnails above post on the THiCK theme

    299 readersI was asked by a reader: I’m using the THiCK theme for my new design blog. I noticed you were able to add thumbnail images above your blog posts on the home page. What would I need to do to enable this on my blog? Well Jon, this can be done very simple, since the theme is

  • How to: Use Thumbnails Generated by WordPress

    243 readersOne of ten brilliant tips that I shared yesterday on my blog – display images on your blog’s homepage without any custom fields or any additional functions.php script, something I first saw on  WebDeveloperPlus. How do you do it? First log in, on the sidebar select ‘Media’ (which is under ‘Settings’). You’ll then be taken

  • chart

    Creating a Chart on Your WordPress Archives Page

    364 readersOne part of WordPress that I've never been overly impressed with is archives. This isn't so much a WordPress problem as it an archive problem, archives are inherently boring. As a result of this revelation I've spent some time thinking up new ways to present the information. My latest idea was adding charts to represent

  • CSS Rounded Tips

    Nifty Rounded Edges Using Only CSS

    328 readersIf you have a Google Analytics account, you must have seen that Google uses slightly rounded edges in the menu buttons on the left. See the picture below :- Today, I will teach you how to give these nifty little rounded edges to your menu. Given below is the CSS code. This goes into the

  • Randomized Grid of Posts

    1639 readersI’m all about tinkering with different ideas to display posts with WordPress. After all, it’s just a bunch of data at our fingertips! WordPress makes it easy to output whatever we need. Not long ago we experimented with making a Thumbnail Based Archives. Now let’s build a Randomized Grid Archives. 1. Create a page template,