I would like to get a gallery automatic. If the page/post have for example 2 or more images, the gallery should apear automatic.
I want to implement this in my theme. Just simulate [gallery] in the theme.
Any idea?
Thanks a lot
I would like to get a gallery automatic. If the page/post have for example 2 or more images, the gallery should apear automatic.
I want to implement this in my theme. Just simulate [gallery] in the theme.
Any idea?
Thanks a lot
You can achieve this by putting the following in your theme's functions.php template:
function auto_gallery($content = '') {
if ( false !== strpos($content, '[gallery') )
return $content;
$image_count = 0;
$kids = get_children();
foreach( (array) $kids as $kid ) {
if ('attachment' == $kid->post_type && 'image/jpeg' == $kid->post_mime_type )
$image_count++;
if ( 1 < $image_count )
return $content . " [gallery]";
}
return $content;
}
add_filter('the_content', 'auto_gallery', 0);Hi, this plugin is working good for me, but i have a small problem.
The gallery is showing on the frontpage, but I want it to show only ath the bottem of a article after clicking on "read more". Is this possible?
This topic has been closed to new replies.