WordPress.org

Support

Support » Plugins and Hacks » Really Simple Gallery Widget » [Resolved] Show in image.php

[Resolved] Show in image.php

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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;
    }

    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.

    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 ‘[Resolved] Show in image.php’ is closed to new replies.
Skip to toolbar