Title: Show in image.php
Last modified: August 20, 2016

---

# Show in image.php

 *  Resolved [lolwp](https://wordpress.org/support/users/lolwp/)
 * (@lolwp)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/show-in-imagephp/)
 * Hi,
 * is there any way for the widget to show other attached images from parent post
   in widget when viewing the image attachment (image.php)?
 * I don’t know any PHP but if it’s a fairly simple change I can copy/paste code
   if you provide it and change the plugin myself.
 * Thanks
 * [http://wordpress.org/extend/plugins/really-simple-gallery-widget/](http://wordpress.org/extend/plugins/really-simple-gallery-widget/)

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

 *  Plugin Author [Helen Hou-Sandi](https://wordpress.org/support/users/helen/)
 * (@helen)
 * Core Lead Developer and 4.0, 4.7, and 5.6 Release Lead
 * [13 years, 5 months ago](https://wordpress.org/support/topic/show-in-imagephp/#post-3310547)
 * Please don’t change the plugin code itself – there are hooks provided for you
   to alter behavior. Altering a plugin or theme directly is never a good idea, 
   as your changes will get wiped out with an update. This should work, in something
   like the theme’s functions.php file (if it’s your own theme) or a custom plugin
   file:
 *     ```
       add_filter( 'rsgw_query_args', 'hhs_attachment_page_rsgw_query_args', 10, 2 );
       function hhs_attachment_page_rsgw_query_args( $query_args, $args ) {
       	global $post;
   
       	if ( 'attachment' == get_post_type() && ! empty( $post->post_parent ) ) {
       		$query_args['post_parent'] = $post->post_parent;
       	}
   
       	return $query_args;
       }
       ```
   
 *  Thread Starter [lolwp](https://wordpress.org/support/users/lolwp/)
 * (@lolwp)
 * [13 years, 5 months ago](https://wordpress.org/support/topic/show-in-imagephp/#post-3310552)
 * Thank you for your response, I could never figure out something like that on 
   my own. Worked perfectly.
 * Just took me about 3 hours to figure out how to display your plugin’s widget 
   only when viewing the attachment page. This is the best I could come up with,
   creating new widget areas and:
 *     ```
       <?php if (is_attachment() ) : ?>
       <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('more-images') ); ?>
                  <?php else : ?>
       <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('not-attachment') ); ?>
   
       	<?php endif; ?>
       ```
   
 * I don’t need it (anymore), but perhaps it’s a feature you might want to consider
   for your plugin.
 * Again, thanks for your help.
 *  [bigu_c](https://wordpress.org/support/users/bigu_c/)
 * (@bigu_c)
 * [12 years, 6 months ago](https://wordpress.org/support/topic/show-in-imagephp/#post-3310712)
 * Hi Helen Hou-Sandi,
 * Your code work fine for me.
 * But how to exclude current image? (current image will not display on sidebar?
 * Thank you.

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

The topic ‘Show in image.php’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/really-simple-gallery-widget.svg)
 * [Really Simple Gallery Widget](https://wordpress.org/plugins/really-simple-gallery-widget/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/really-simple-gallery-widget/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/really-simple-gallery-widget/)
 * [Active Topics](https://wordpress.org/support/plugin/really-simple-gallery-widget/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/really-simple-gallery-widget/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/really-simple-gallery-widget/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [bigu_c](https://wordpress.org/support/users/bigu_c/)
 * Last activity: [12 years, 6 months ago](https://wordpress.org/support/topic/show-in-imagephp/#post-3310712)
 * Status: resolved