Revision: 17291
Updated Code
at September 19, 2009 12:19 by tylersticka
Updated Code
<?php
// http://tylersticka.com/2009/09/wcpdx09/
// Function retrieve a set of portfolio items
function get_work(
// Specify a portfolio item ID to exclude from results,
// useful if displaying a list of other items in an item page
$exclude=null,
// The number of portfolio items to return to
// (Returns all by default)
$limit=-1,
// The ID of the "master" portfolio page. To streamline use
// of the function, change the default of this to whatever
// the ID of the portfolio page is
$parent=3,
// Advanced arguments if you wish to make other adjustments
$args = array('orderby'=>'menu_order','order'=>'ASC','post_type'=>'page')
) {
// Add arguments to query when applicable
$args['numberposts'] = $limit;
if ($exclude) { $args['exclude'] = $exclude; }
if ($parent) { $args['post_parent'] = $parent; }
// Fetch and return WordPress posts matching query
return get_posts($args);
}
?>
Revision: 17290
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at August 30, 2009 17:48 by tylersticka
Initial Code
<?php
// Function retrieve a set of portfolio items
function get_work(
// Specify a portfolio item ID to exclude from results,
// useful if displaying a list of other items in an item page
$exclude=null,
// The number of portfolio items to return to
// (Returns all by default)
$limit=-1,
// The ID of the "master" portfolio page. To streamline use
// of the function, change the default of this to whatever
// the ID of the portfolio page is
$parent=3,
// Advanced arguments if you wish to make other adjustments
$args = array('orderby'=>'menu_order','order'=>'ASC','post_type'=>'page')
) {
// Add arguments to query when applicable
$args['numberposts'] = $limit;
if ($exclude) { $args['exclude'] = $exclude; }
if ($parent) { $args['post_parent'] = $parent; }
// Fetch and return WordPress posts matching query
return get_posts($args);
}
?>
Initial URL
http://tylersticka.com/2009/09/wcpdx09/
Initial Description
For use in the theme functions template, functions.php.
Initial Title
WordPress-Powered Portfolios: get_work()
Initial Tags
wordpress
Initial Language
PHP