WordPress-Powered Portfolios: get_work()


/ Published in: PHP
Save to your folder(s)

For use in the theme functions template, functions.php.


Copy this code and paste it in your HTML
  1. <?php
  2. // http://tylersticka.com/2009/09/wcpdx09/
  3. // Function retrieve a set of portfolio items
  4. function get_work(
  5. // Specify a portfolio item ID to exclude from results,
  6. // useful if displaying a list of other items in an item page
  7. $exclude=null,
  8. // The number of portfolio items to return to
  9. // (Returns all by default)
  10. $limit=-1,
  11. // The ID of the "master" portfolio page. To streamline use
  12. // of the function, change the default of this to whatever
  13. // the ID of the portfolio page is
  14. $parent=3,
  15. // Advanced arguments if you wish to make other adjustments
  16. $args = array('orderby'=>'menu_order','order'=>'ASC','post_type'=>'page')
  17. ) {
  18. // Add arguments to query when applicable
  19. $args['numberposts'] = $limit;
  20. if ($exclude) { $args['exclude'] = $exclude; }
  21. if ($parent) { $args['post_parent'] = $parent; }
  22.  
  23. // Fetch and return WordPress posts matching query
  24. return get_posts($args);
  25. }
  26. ?>

URL: http://tylersticka.com/2009/09/wcpdx09/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.