mercredi 6 juillet 2016

Modifying WordPress Query --> Order By Custom Value In Another Table


I created a new additional table that ranks the posts similar to the one below: ------------------ | post_id | rank | | 6 | 3 | | 4 | 1 | | 5 | 2 | ------------------ I'd like to sort the posts in my site's search results so that they're ordered by the ranks from this custom table. I would like to leverage WP's built in functions but is there a way to do that using $query->set()? if ($query->is_search) { ... $query->set('orderby', ???); ... }

Aucun commentaire:

Enregistrer un commentaire