Code For Use on Category Archive Pages
-
Was hoping you might add a couple lines of code to this plugin to enable it to work on Category pages.
Using other plugins like Advanced Custom Fields, I am able to add WYSIWYG editors to categories and taxonomies, and use that to display galleries within the Category Pages. Yes, I am aware this is a more unique case use, but with just a couple lines of code, I was able to make this work.
In your public static function called apply_filter_post_gallery, you are testing for a shortcode attribute ID or the post ID. In the final “else” where you are bailing on the gallery, I added the following:
$queried_object = get_queried_object(); $taxonomy = $queried_object->taxonomy; $post_id = $queried_object->term_id; if( !$post_id ) return ' ';
As you can see, I am still doing a simple return if we still have nothing.
On another note, without this change, on Categories, I am getting nothing… your bail method kills the gallery completely. The only other option is to disable the plugin. May want to consider at least returning the default gallery if nothing is found, just in case.
If you could add the few lines I mentioned, that would give a bit more flexibility to the plugin, and it would help ensure the minor changes I made aren’t killed off if the plugin ever gets updated.
Thanks, and I certainly appreciate your plugin!
Edhttps://www.ads-software.com/plugins/wp-gallery-custom-links/
- The topic ‘Code For Use on Category Archive Pages’ is closed to new replies.