Skip to content

Instantly share code, notes, and snippets.

@tribulant
Created May 8, 2015 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tribulant/6bbeffe30deb3ec2e44a to your computer and use it in GitHub Desktop.
Save tribulant/6bbeffe30deb3ec2e44a to your computer and use it in GitHub Desktop.
global $post;
$pid = (empty($post_id)) ? $post -> ID : $post_id;
if (!empty($pid) && $post = get_post($pid)) {
$children_attributes = array(
'numberposts' => $numberposts,
'post_parent' => $post -> ID,
'post_type' => "attachment",
'post_status' => "any",
'post_mime_type' => "image",
'orderby' => $orderby,
'order' => $order,
);
if ($attachments = get_children($children_attributes)) {
//if ($attachments = get_children("post_parent=" . $post -> ID . "&post_type=attachment&post_mime_type=image&orderby=" . ((!empty($orderby) && $orderby == "random") ? "rand" : "menu_order ASC, ID ASC"))) {
if (!empty($exclude)) {
$exclude = array_map('trim', explode(',', $exclude));
$a = 0;
foreach ($attachments as $id => $attachment) {
$a++;
if (in_array($a, $exclude)) {
unset($attachments[$id]);
}
}
}
if ($orderby == "random") { shuffle($attachments); }
$content = $this -> render('gallery', array('slides' => $attachments, 'unique' => $pid, 'options' => $s, 'frompost' => true), false, 'default');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment