Post gallery loop with thumb and full size

There might be other possibilities to this, mine is given below .. First you use the get_post_gallery function to store the image id’s in a separate array .. if ( get_post_gallery() ) { $gallery = get_post_gallery( get_the_ID(), false ); $galleryIDS[] = array(); /* Loop through all the image and store them one by one */ … Read more

How to move WordPress gallery image out of the link?

You can use the post_gallery filter for the job and replace wp_get_attachment_link() with wp_get_attachment_image(). Something like: add_filter( ‘post_gallery’, ‘post_gallery_wpse219434’, 10, 2 ); function post_gallery_wpse219434( $output, $attr) { global $post, $wp_locale; static $instance = 0; $instance++; // We’re trusting author input, so let’s at least make sure it looks like a valid orderby statement if ( … Read more

Replace custom gallery shortcode with default gallery shortcode

Either make a regex filter as a the_content filter, add_filter(‘the_content’, ‘my_regex_filter’, 1); // Execute as early as possible function my_regex_filter($content) { $regex = get_shortcode_regex(array(‘showgallery’)); $content = preg_replace(“https://wordpress.stackexchange.com/”.$regex.’/s’, ‘[$1gallery$3$4$5$6]’, $content ); return $content; } or rewrite your add_shortcode function. remove_shortcode(‘showgallery’); add_shortcode(‘showgallery’, ‘my_showgallery’); function my_showgallery($args) { return gallery_shortcode($args); } I would recommend the second, because it is … Read more

Pulling in Column Count in Custom Gallery

Sprintf is a way to use variables within a string easily. %d designates a digit and %s is any string. So think of it like this sprintf( ‘<div class=”%s”>%s</div>’, $var1, $var2 ); So for your example, you’d need something like: $output = sprintf( ‘<div class=”gallery gallery-columns-%s” itemprop=”image” itemscope itemtype=”http://schema.org/ImageGallery”>%s</div>’, $columns, $output ); The only thing … Read more

Attachment Metadata inside of Loop

Here’s the fix. All the attachment info is now being called inside the php using wp_prepare_attachment_for_js and the info will load for each image in the loop, to display in the photo gallery. It works now. <?php $the_query = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘category_name’ => ‘arch’ )); while ( $the_query->have_posts() ) … Read more

Automatically add class-attribute to gallery?

If you take a look at native galleries they already have IDs with counter implemented: $instance++; … $selector = “gallery-{$instance}”; … $gallery_div = “<div id=’$selector’class=”gallery… So first gallery within a post will have <div id=”gallery-1″… and so on. This is used by core itself to target different styles at each instance. If you need to … Read more

How to add 2 variable rewrite rule?

You’ll need to write a rewrite rule to parse the URL and pull out the value of gallery-name and gallery-item-name. This will be tricky as there is nothing to distinguish your proposed URL structure from a hierarchical page structure. If you can throw in something that is always the same for all gallery URLs like … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)