Priority groups allow prioritizing certain posts (or any CPT) based on custom field or taxonomy term rule(s).
When is this feature useful?
When certain posts in (or not in) certain category (or more categories) should be displayed first.
Example: Posts from category "Blog" should be displayed first, then the rest of the results.
When posts having a certain custom field (post meta) and value should be displayed first.
Example: Products between prices 1-100 should be displayed first, then the others.
..any combination of the above.
Example: Products within the "T-shirt" category and below price 500 should be dispayed first.
How it works?
You can create groups and then add rules to them. Each group has a "group priority" value assigned (by you), and results matching those rules get this value. The results are then ordered by this group priority value first.
Results that does not match any priority group, get the group priority value 1.
Adding a group
Clicking on the Add new button a pop-up will appear, that will allow:
Changing the group name
Setting the priority - by default this is set to 100. This value should be kept between 1-5000
Change which search instances the rule should apply to
Adjust which phrases the rules should apply on
Also the logic, if all rules should apply, or only one is sufficient
Clicking on the 'New rule' button will open the rule editor, where you can:
Assign a rule name
Change the rule type - either Custom field or Taxonomy term
Change the operator - this is how the values are compared to the results
Enter the value(s)
After you have choosen the desired options, hit the 'Save rule' button, and the rule should appear on the list.
Editing and Deleting rules
To edit a rule click on the Settings icon by the rule name. The X icon will open a prompt to delete a rule. Deleting a rule is also possible by clicking on the 'Delete rule' button in the editor.
These are some specific examples, to show how these options may affect the results.
Let's assume we have a blog (similar to the plugin demo), where the posts are in the following main categories: Actors, Cars, Food, Metropolitan areas and Movies
There are also products (WooCommerce defaults), within the following main categories: Clothing, Musing, Posters, TV
Example #1: Prioritizing posts based on categories
We would like the posts in the following order, based on categories:
Food, Movies (any of the categories match)
Rest of the categories
For this we will need 2 priority groups, one for the Movies and one for the Food and Cars categories:
Then the second group:
After creating the two groups, the results are displayed as desired: