Home › Forums › Feature Requests › Speed up work with new option in gallery field › Reply To: Speed up work with new option in gallery field
I tried to put it in gallery.php, and functions.php, but suppose problem might lie here
<?php
add_filter( 'post_gallery', 'authentic_post_gallery', 10, 3 );
function authentic_post_gallery( $output = '', $atts, $instance ) {
$post = get_post();
$default = array(
'id' => $post ? $post->ID : 0,
'order' => 'ASC',
'orderby' => 'menu_order ID',
'columns' => 3,
'size' => 'thumbnail',
);
$atts = array_merge($default, $atts);
$id = intval( $atts['id'] );
if ( ! empty( $atts['include'] ) ) {
$_attachments = get_posts( array( 'include' => $atts['include'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
$attachments = array();
foreach ( $_attachments as $key => $val ) {
$attachments[$val->ID] = $_attachments[$key];
}
} elseif ( ! empty( $atts['exclude'] ) ) {
$attachments = get_children( array( 'post_parent' => $id, 'exclude' => $atts['exclude'], 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
} else {
$attachments = get_children( array( 'post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $atts['order'], 'orderby' => $atts['orderby'] ) );
}
if ( empty( $attachments ) ) {
return '';
}
$selector = "gallery-{$instance}";
if (isset($atts['layout'])) {
$layout = $atts['layout'];
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.