raamdev/wp-snippets

Feature Request: Random Snippets

Opened this issue · 5 comments

It would be nice if it was possible to randomly pull in any snippet from a specific category (e.g., "Testimonials"). This could be a simply enhancement to the Snippets shortcode: [snippet category="testimonials" /].

Referencing: https://github.com/websharks/s2member.com/issues/15#issuecomment-88604067

Marking this as ready for work. Thanks!

Partial completion. While it is not possible to do a random category yet, the following is now possible.

[snippet slug="random:sluga,slugb,slugc" /]

A random slug is selected from the comma-delimited list you supply.

Sweet!

@jaswsinc DIscussion in https://github.com/websharks/cometcache.com/issues/105#issuecomment-268406592 brought me back to this issue, as I think we can use WP Snippets for testimonials and it would be nice to be able to display a random snippet from a "Testimonials" category. However, needing to create a list of slugs for the randomization pool is less than ideal for this scenario.

Any chance you can add support for a random snippet from a given category sometime soon? 😁 Something like [snippet slug="random_in_cat:category-slug" /] maybe?

Yes, I can certainly do that. I had the same thought yesterday whenever you asked this, but this little project is in need of a revamp. Shouldn't take long though, it's a pretty simple plugin. I'll add this in soon whenever I do some other work to get this working in WP 4.7. I have to do that anyway, because this plugin is currently preventing me from upgrading one of our sites to WP 4.7.