• Resolved doctordark

    (@doctordark)


    Hello, I’m trying to reorder results post list with this hook and according to “apply_filters( ‘relevanssi_admin_search_element’, $post_element );”:

    function swap_function($post_element) {
    $post_element = <<<EOH
    <li>$blog_name <strong>$title</strong> $edit_link $pinning_buttons <br />
    $post->post_excerpt<br />
    $score_label $post->relevance_score $pinned</li>
    EOH;
    return $post_element;
    }
    add_filter('relevanssi_admin_search_element', 'swap_function');

    But it is not working, it’ll just show empty results

    Any help would be greatly appreciated! Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mikko Saari

    (@msaari)

    What are you trying to do exactly? How are you trying to reorder the results? This function does no reordering, it just blanks out the results, because none of those variables used in the function are defined, that’s why the results are coming up empty.

    If you want to modify the way the results look like in the admin search, this is the right filter, but you need to work with the existing $post_element and reorder what is inside it (see what the function contains).

    Thread Starter doctordark

    (@doctordark)

    Yes, I can reorder them inside the function of the plugin, but what I was trying to accomplish is to have the “replacement code” in my child theme functions so the changes sticks around when the plugin updates.
    I can see now that i was going nowhere haha

    Thanks!

    Plugin Author Mikko Saari

    (@msaari)

    Yes, the filter doesn’t allow reordering the template, you need to work with the generated HTML.

    Thread Starter doctordark

    (@doctordark)

    I modified it directly from the function itself, as I wanted to reorder it but for the Admin Search

    I’ll mark this has SOLVED

    Thanks Mikko.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Customize results post list’ is closed to new replies.