Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SearchWP 2.3 will make available all of the weights that dictated the order of search results
<?php
print_r( SWP()->results_weights );
/* ===================== OUTPUT =====================
Primary array key is the $post->ID, each primary value contains the overall
weight for that $post in addition to the weight for each post type
Array
(
[1778] => Array
(
[post_id] => 1778
[weight] => 100
[post_types] => Array
(
[post] => 100
[page] => 0
[cpt1] => 0
[attachment] => 0
)
)
[801] => Array
(
[post_id] => 801
[weight] => 80
[post_types] => Array
(
[post] => 80
[page] => 0
[cpt1] => 0
[attachment] => 0
)
)
[2424] => Array
(
[post_id] => 2424
[weight] => 60
[post_types] => Array
(
[post] => 60
[page] => 0
[cpt1] => 0
[attachment] => 0
)
)
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment