GreenInfo-Network / WP_Query_WithRelevance

Wordpress WP_Query subclass which adds relevance sorting
MIT License
0 stars 0 forks source link

tax_query = use slugs or IDs #2

Closed gregallensworth closed 6 years ago

gregallensworth commented 6 years ago

At present, score_taxonomy_relevance() presumes that terms are IDs. The get_the_terms() loop checks the ID against the $queried_term_ids but wouldn't check a slug.

https://github.com/GreenInfo-Network/WP_Query_WithRelevance/blob/master/wpquery_withrelevance.php#L98

Have it also check the slug as being in the list, so one may freely use IDs and/or slugs.

gregallensworth commented 6 years ago

The tax_query will now check whatever field is specified in the field parameter, e.g. term_id, name,slug or term_taxonomy_id This should cover every possible case.

The resulting loop is a bit larger and perhaps slower, but still quite acceptable. And this wider loop, also lays the groundwork for #3 in which each taxo may use a different weight coefficient.