/ Published in: PHP
For use in conjunction with the get_work function in the theme functions template, functions.php.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // http://tylersticka.com/2009/09/wcpdx09/ // Function to display a list of portfolio items // Same arguments as get_work function list_work($exclude=null, $limit=-1, $parent=3, $args = array('orderby'=>'menu_order','order'=>'ASC','post_type'=>'page')) { // Retrieve a set of work results $work = get_work($exclude,$limit,$parent,$args); // If work is successfully retrieved, build the list if ($work) : ?> <ul> <?php // Loop through each item foreach ($work as $item) : // Grab the item's custom meta $fields = get_post_custom($item->ID); // Build the list item, with a linked thumbnail and title ?> <li><a href="<?php echo get_permalink($item->ID) ?>"> <img src="<?php echo $fields['tn'][0] ?>" alt="" /> <?php echo apply_filters('the_title',$item->post_title); ?> </a></li> <?php endforeach; ?> </ul> <?php // If no work is found, display an error message else : ?> <p>Our apologies, but we have yet to add any examples of our work. Check back soon!</p> <?php endif; } ?>
URL: http://tylersticka.com/2009/09/wcpdx09/