• Resolved ckubs

    (@ckubs)


    Looked for some related post plugins and sticked to yours since it was versatile enough and lightweight. I have one problem though. When I have related posts under an article with a WP gallery in it, the gallery takes some CSS styles from the plugin and the plugin some styles from the WP gallery. And for example if I have an article with 3 columns gallery and I want my plugin shortcode to output 2 post columns with large images, my wp gallery gets transformed to 2 columns large images.

    As I see your plugin and the WP gallery share the same CSS classes. I can do something about that?

    https://www.ads-software.com/plugins/related-posts-by-taxonomy/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi ckubs
    Can you share a link to a page with the problem.
    What theme do you use?

    As I see your plugin and the WP gallery share the same CSS classes. I can do something about that?

    Yes, they even share the same Html markup. If you want to style the related galleries differently you can use the class .related-gallery

    See this for the markup and styling of the related post thumbnail gallery: https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/post-thumbnails/#markup

    Thread Starter ckubs

    (@ckubs)

    I sorted out the problem. Since wordpress galleries aren’t responsive by default, I had also installed a plugin that adds masonry to WP gallery( this one https://www.ads-software.com/plugins/jquery-masonry-image-gallery/ ). And it added it’s style to WP galleries as normal and to related posts since they shared almost everything, but only to the ones under the articles containing a gallery, not all of them and I had different styling for your plugin output.

    Now I disabled masonry and sadly lost my galleries responsiveness but things look as they should, I guess. As you may see https://goo.gl/GHNWCB

    Plugin Author keesiemeijer

    (@keesiemeijer)

    I’m glad you found out what was happening. I’m guessing the masonry plugin gets the galleries from the class “.gallery”. The related posts galleries use the same class name. This plugin does this so it doesn’t have to do any styling for the related galleries.

    To remove the “.gallery” classname from related galleries you can use this in your theme’s functions.php.

    add_filter( 'gallery_style', 'related_posts_gallery_style' );
    
    function related_posts_gallery_style( $style ) {
    	if ( preg_match( "/class='gallery related-gallery /", $style ) ) {
    		$style = preg_replace( "/class='gallery related-gallery /", "class='related-gallery ", $style );
    	}
    	return $style;
    }

    Check if the masonry plugin and this plugin work together if you do this. It still means you’ll have to style the related galleries yourself (.related-gallery).

    btw:
    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PLugin messing my galleries’ is closed to new replies.