• 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

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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);
    112fryslan

    (@112fryslan)

    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?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘gallery 2.5 automatic’ is closed to new replies.