Keyword filtering capability request
-
Hello, I was wondering if it would be possible to extend this plugin by a developer or part of a feature request for you – it would be interesting to add a shortcode parameter named “keyword”, which would filter the reviews containing the keywords, so for example we would have keywords=”professional, expert”, the widget would pull only reviews that contain “professional” and “expert” in their texts.
Let me know if this is feasible as a custom extension to this or is a more complicated change.
-
@alexandrubagi I’ve already added this functionality to the Shortcode. Please check out this parameter:
[reviews_rating review_text_inc="professional, expert"]Please view this and many other parameters in the plugin’s Settings | Shortcodes tab.
The Widget is a little more basic because there’s only so much space in there. It would not be feasible to cram all the functionality and options into this without confusing too many people.
If you’re enjoying the plugin and its functionality, please leave a review. 🙂
It’s actually a really well-done plugin, I love it. Do you think it would be possible to add a function to the review_text_inc parameter so I could provide the keywords contextually? Eg if I would want to add the widget on a post sidebar, and fetch keywords from a post’s title or metafields, I can write a function to get that data, but I was wondering how I could pass it to the shortcode. Perhaps wrapping your shortcode into another one?
@alexandrubagi I recommend placing the Shortcode within the Custom HTML Widget – then you can use all the parameters available whilst appearing in the Sidebar.
Please expand the “keywords” idea, how does this differ from the current functionality that checks for words within the review text?
And thanks so much for the ★★★★★ review!
Thank you for the suggestion – that was indeed what was I planning to do.
The idea I was thinking about was to offer some kind of contextual functionality. Let’s assume we have a single post page template which has a sidebar. On that sidebar, I would like to display the Google Reviews widget.
A nice-to-have feature would be to offer some kind of “contextual intelligence” to the widget based on the post page. For example, Post #1 title is “Replacing oil for your car engine”, Post #2 title is “Replacing filters” and Post #3 title is “Gearbox maintenance”. It would be nice to have the widget display different reviews based on the words in the title. Of course, there are tons of ways to specify which words to pick and/or filter, but perhaps a callback parameter or a hook for the shortcode would do wonders, at least in my situation. I would be able to write a function that picks some keywords from, let’s say Yoast meta fields, and the callback function returns an array with the first 3 words on which to filter.
So the widget shortcode would look something like this –
[reviews_rating review_text_inc_callback=”my_function_or_filter_name”]
my_function_or_filter_name function will perform a lookup based on the current post, fetch the keywords (it’s up to the developer – me – to write this piece of code) and will return an array of keywords so your plugin would do the filtering part.
I hope I was clear with the specifications, this is the kind of feature I was thinking to implement in one of the websites, and I would love to extend this plugin to offer this functionality.
-
This reply was modified 5 years, 1 month ago by
alexandrubagi.
@alexandrubagi Looking at the functionality here, if you’re looking to display just one, specific review, I would recommend using the ID parameter:
[reviews_rating id="45"]You can select just one or have a comma separated list of these (the ordering of these is applied).
This may be better because you’ll be able to scan over the reviews and find those that are relevant to a particular page or section that may not work with an inclusive word search of the review text.
You can add titles in the content proper before the Shortcode (or as the Widget’s title). There is nothing in the plugin itself to handle titles for individual reviews (sometimes seen in other reviews or testimonials). I have kept this plugin as a mirror version to Google’s own review system that doesn’t use a summary title for the review text. This is something I may extend, probably in a premium, multi-location version of the plugin.
Coming back to the callback function, if you want to go down this path you could do something in reverse – write your own Shortcode that will perform a search of the plugin’s data (located in the options table) and return the ID of that review to use in the
do_shortcode()function using the suggested ID parameter (above).For example:
function my_special_review() { global $post; $review_title = NULL; $review_id = NULL; // Code to handle current page // ... // Find a good review // ... $html = '<h3>' . esc_html($review_title) . '</h3>' . do_shortcode('[reviews_rating id="' . intval($review_id) . '" summary=false attribution=false]'); return $html; }In the handler function, you could include a title to place above the
do_shortcode()call.Making a handler function for this or a new parameter as suggested isn’t really something that I want to code right now – I feel it’s quite unique to a few instances and I need to be sure that all new functionality is easy to understand or at least has a concept that could be understood and applied to various situations. However, everything is available for you to make something as suggested that would give you the control you need.
Let me know how this sounds?
-
This reply was modified 5 years, 1 month ago by
Noah Hearle. Reason: Added an actual PHP function example
-
This reply was modified 5 years, 1 month ago by
The topic ‘Keyword filtering capability request’ is closed to new replies.