Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Core search ‘orderby’

Discussion in 'Misc WordPress Requests' started by sergnaste, Feb 8, 2018.

  1. sergnaste

    Guest

    Core search ‘orderby’, by sergnaste

    Hi!
    When I use core search ( search form ) the results are ordered not as I expect. Then I went to core files ( to class-wp-query.php ) I found out strange thing. A lot of conditions was forming $orderby variable in the function get_posts() and it was correct ( I mean it contains “full match in the title, all terms in the title, at least one of the terms in the title, terms in the content). But on the line 2612 this varible is overwrite by string
    $orderby = isset( $clauses[ ‘orderby’ ] ) ? $clauses[ ‘orderby’ ] : ”;
    And the same happened on the line 2736
    $orderby = isset( $clauses[ ‘orderby’ ] ) ? $clauses[ ‘orderby’ ] : ”;
    $clauses[‘orderby’] contains simple orderby condition ( like posts by DESC ).
    And that little confused me.

    Can somebody explain me, why is variable $orderby marked as ‘not used’ and be overwrited by strings which I’ve written above ?

    Thank yoy in advance.

    Core search ‘orderby’
     
    #1

Share This Page

Monarch Social Sharing Plugin