我想展示画廊的标题和标题。下面是我的尝试,但我一直Notice: Trying to get property of non-object
. 我还是不知道出了什么问题。
仅有一个的php
<div class="gallery-content">
<?php
add_filter( \'shortcode_atts_gallery\', \'fullsize_gallery\' );
if( has_shortcode( $post->post_content, \'gallery\' ) ) :
$gallery = get_post_gallery_images( $post->ID );
$image_list = \'<ul class="galleryslider" style="display: none;">\';
foreach( $gallery as $image ) :
$image_title = wp_get_attachment_url($image->post_title);
$image_caption = wp_get_attachment_url($image->post_excerpt);
// Loop through each image in each gallery
$image_list .= \'<li><a href="\'. $image . \'" data-lightbox="\'.$post->ID.\'"><img src="\' . $image . \'" title="\'.$image_title.\'"/>\'.$image_caption.\'</a></li>\';
endforeach;
$image_list .= \'</ul>\';
echo $image_list;
endif;
?>
</div><!-- .gallery-content -->
功能。php
function fullsize_gallery( $out )
{
remove_filter( current_filter(), __FUNCTION__ );
$out[\'size\'] = \'full\';
return $out;
}