Comments on: How to Render Your Own WordPress Photo Gallery http://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery Adventures in WordPress Fri, 17 Oct 2014 19:18:04 +0000 hourly 1 http://wordpress.org/?v=4.0 By: Dave McCourthttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-205486 Sun, 27 Jul 2014 14:38:26 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-205486 Ket, if you return the output and the use the_content() filter, it works inline (ie wherever you put your gallery in the post editor):


remove_shortcode('gallery');
add_shortcode('gallery', 'parse_gallery_shortcode');

function gallery_output_in_the_content($content) {
$g = parse_gallery_shortcode();
$custom_content = $g;
$custom_content .= $content;
return $custom_content;
}

add_filter('the_content', 'gallery_output_in_the_content');

function parse_gallery_shortcode($atts) {
… as above but with this extra code:

$gal .= '';

foreach ($images as $image) {
$caption = $image->post_excerpt;

$description = $image->post_content;
if($description == '') $description = $image->post_title;

$image_alt = get_post_meta($image->ID,'_wp_attachment_image_alt', true);

// render your gallery here
$gal .= '';
$img_meta = wp_get_attachment_metadata($image->ID);
$img = wp_get_attachment_image_src($image->ID, 'gallery-small');
$img_big = wp_get_attachment_image_src($image->ID, 'gallery-big');
$gal .= '';
if (strlen($caption) > 0) $gal .= '' . $caption . '';
$gal .= '';
}

$gal .= '';

return $gal;
}

]]>
By: kethttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-130202 Sun, 25 May 2014 13:30:09 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-130202 This code pushes text down to below the gallery. How to show gallery below or between text content.

]]>
By: Leonhttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-95587 Wed, 19 Mar 2014 17:12:23 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-95587 This example been extremely helpful, thank you!

]]>
By: Jimmyhttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-91339 Sun, 24 Nov 2013 02:16:17 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-91339 Hi there,

trying to display the gallery – as in the kin theme.

i am using wordpress 3.7

I created the plugin and added the first bit

then i added the second bit got errors
so i tried to add it to my functions file got the same error

tried to paste it into the page template not working there

any help would be great

]]>
By: Elliothttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-88170 Fri, 08 Nov 2013 13:24:40 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-88170 This looks like a great solution, but when I activate the plugin, all the images in the editor’s Media popup disappear. Any idea why this might be happening?

]]>
By: ShibaShakehttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-85534 Sat, 19 Oct 2013 04:11:25 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-85534 This is an older article, written before the 3.5 update where individual image ids are specified, rather than using the parent-attach system. Refer to http://codex.wordpress.org/Gallery_Shortcode for a summary of shortcode history and the old vs. new media flow.

ADD: I have just updated the article above to handle id lists.

]]>
By: Nicholashttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-85525 Sat, 19 Oct 2013 02:57:31 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-85525 Hey I don’t mean to criticize but your code is really not doing the right thing. Firstly as some other comments shared, you are pulling all attachments inside the post, not just from that gallery. The other problem with doing this is the function will no longer respects the order by which the images were set up in the gallery; it is passed as $atts to the shortcode function but disregarded completely.

]]>
By: Colirhttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-81292 Wed, 25 Sep 2013 12:32:27 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-81292 Hi,
thanks for the tips.
However i’ve a problem. i’have multiple gallery in a post, and with your code, each gallery display all attachment image to the post.
How to only have the images that are in each gallery ?
thanks

]]>
By: Darzanhttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-78225 Fri, 09 Aug 2013 08:38:44 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-78225 Hi,
I just need a line of code to write instead of your “render your gallery here” only to publish the images, but I can’t understand which variable to use!
I’m not so good with PHP…
Can you please help?

]]>
By: NCPRhttp://shibashake.com/wordpress-theme/how-to-render-your-own-wordpress-photo-gallery/comment-page-1#comment-70088 Mon, 08 Apr 2013 13:30:34 +0000 http://www.shibashake.com/wordpress-theme/?p=3011#comment-70088 Question; after doing all of this I still cannot scroll through my photos that are in my gallery. There is no “next” button. When I click on an image it just loads that one image and I have to click the back button and find where I was in the gallery to click on the next one. Is there an easy way to fix this?
Thanks

]]>