Forums Forums Search & Filter Pro Define posts to display first using custom fields

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #97607

    Hi, I have about 15 artists to display in the search results, and I’d like to be able to define one of the “best” or most representative pieces of art to display first for each artist, even after more posts continue to be added, so that they don’t get lost in the mix. This would be very useful in the first look at the search form, where no filters have been applied, as well as in a very broad search, where one search term results in several artists, with dozens of examples each.

    I have custom fields working in the results.php already, so the image results can link directly to the artist page defined in the custom field, like this:

    <?php
      if ( has_post_thumbnail() ) { ?>
        <span class="responsive"><a href="<?php echo get_post_meta($query->post->ID,'artistpage',true); ?>">

    It seems like I should also be able to say, “display featured results first, then display as usual.” Do you think this is possible?

    Liz

    Trevor
    #97937

    If the data as to which is in a custom field, you can sort by the meta key as a secondary sort key (you will need to set the primary sort key first) in the Posts settings tab of the form?

    Anonymous
    #99406

    Hi, I took some time to play around with the primary and secondary sort keys, and I had some unexpected results. I set the primary sort to “Random order / Descending,” and then set the Secondary sort to “Meta value / ascending / featuredproject / numerical”. I set a post to the custom field “featured project / 1”. The result was that when I input the first search filter, the result was random with no featured project first, and when I clicked refresh, it was filtered down to only the single featured project. (I was hoping to highlight the featured projects first in the results, and then show all the rest afterwards in random order).

    I’m not sure if I set this up correctly, so let me know if there is a better way to try. I’d be willing to try manipulating other filters to accomplish this.

    Thanks for helping me understand how the filter works,

    Liz

    Trevor
    #99408

    Be wary of using random order, as posts can be repeated across pages, as the content of each page is random. WordPress does not randomly sort the posts and then give them to you page after page. It random sorts them again and again for each page, and thus pagination becomes pointless.

    Also, numerous plugins and themes have been known to override sorting, so be aware that such interference can happen.

Viewing 4 posts - 1 through 4 (of 4 total)