Forums

gallery 2.5 automatic (3 posts)

  1. sugoro
    Member
    Posted 4 years ago #

    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

  2. Austin Matzko
    Member
    Posted 4 years ago #

    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);
  3. 112fryslan
    Member
    Posted 4 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.