Tag Info

New answers tagged


WordPress doesn't make it very easy to modify aspects of the gallery shortcode. Some attributions: Thanks to user peterbra for really putting the whole thing together a year ago. Thanks to user birgire for coming up with a solution as far as adding the attribute in a meaningful way. The other option besides birgires ( as far as I know ) is to pretty ...


To determine the best filter to use, you have to determine what those pages are. Is is_page() true? Use the page_template filter. Is is_post_type_archive() true? Use the archive_template filter. All of the query type-specific template filters are listed here. You can also use the generic template_include, which fires for all types. Within any of these ...


Here are three methods Approach #1 It's common to wrap the output with custom HTML. We can do that by using the post_gallery filter and the gallery_shortcode() callback: /** * HTML Wrapper - Support for a custom class attribute in the native gallery shortcode */ add_filter( 'post_gallery', function( $html, $attr, $instance ) { if( isset( ...


I was wanting to do the same as the OP. I have a self-hosted WordPress site where I wanted to display clients' proof images in a post, but I didn't want to host them on our server. I've just opened a Zenfolio account, and it's going to cost me $85 AUD a year for their basic package, but that is fine. The great thing for me is that by using the ...


All those complex functions can be reduced to one simple function: attachment_url_to_postid() You only need to parse the image URL to retrieve the attachment ID: $attachment_id = attachment_url_to_postid( $image_url ); echo $attachment_id; That's all you need.


The gallery is a shortcode, so you will need to parse the shortcode to grab the image referenced therein: function pull_image_from_gallery(){ global $post; $pattern = get_shortcode_regex(); preg_match_all( '/'. $pattern .'/s', $post->post_content, $matches ); foreach ($matches[2] as $k=>$v) { if ('gallery' == $v) { $atts = ...


As of 2015 and NextGen 2.0. Don't hack this, use shortcodes to display a single image and then lead to the lightbox: [ngg_images gallery_ids=7 display_type=photocrati-nextgen_basic_thumbnails disable_pagination=1 images_per_page=1 show_all_in_lightbox=1 show_slideshow_link=0] Further documentation and useful examples.

Top 50 recent answers are included