Get Pages with Status

Download Get Pages with Status at WordPress.org

This is a quick hack to the default WordPress function get_pages(). We’ve extended it to allow you to get pages that are of any status. This can be useful if you’re using WordPress as a CMS and for some reason need to display content from an unpublished page.

We add the single argument ‘status’ to the default list of arguments accepted by get_pages(). You can define status as ‘all’ (or include a specific status type if you’re so inclined). Here’s a quick example:

$getChildren = get_pages_with_status('child_of=17&status=all');
foreach($getChildren as $child) {
 $imageArray =& get_children('post_type=attachment&post_mime_type=image&orderby=menu_order&order=asc&post_parent=' . $child->ID );
 if (is_array($imageArray)) {
 shuffle($imageArray);
 foreach($imageArray as $image) {
 echo wp_get_attachment_image($image->ID, 'alternate');
 }
 }
}

The above snippet produces Real Equity Asset’s Gallery which needed to include unavailable properties.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.