Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1406513

    if you start a search – the ajax results shows a sorting : posts, pages, media as h4 heading – then the results.
    Is it possible to have that for the search results page too?
    _______
    I have a search result page on which I also display media files. My goal is not to open the attachment page for media files, but to open the lightbox directly.
    Pages/contributions etc. should then call up the individual contributions normally.

    ___________

    For what i try to get – it might be enough if there are f.e. classes on each article slide-entry that expresses the post-type of the link.

    #1406654

    ok – i edited the postslider.php – and for what i like to have i only added just before output article this:
    ( on Enfold 5.6 in postslider.php just before line 937 )

    if( get_post_type( $the_id ) == 'attachment' ){
      $post_class .= 'posttype-attachment ';
    }

    or more common – if you like to add any post-type as class on articles:

    $posttype = get_post_type( $the_id );
    $post_class .= 'posttype-'.$posttype. ' ';

    so if the post_type is attachment this will be found as class to slide_entry. After that it is easy to change the link behavior to not open the attachment page but to open directly a lightbox.

    #1406738

    Hi,

    In 5.6.1 the second solution is implemented:

    
    $posttype = get_post_type( $the_id );
    $post_class .= 'posttype-' . $posttype . ' ';
    

    Best regards,
    Günter

    #1406810

    i saw in the code of postslider.php a lot “post_type” notations so i do not try to use it to disturb any other setting. Thats the reason for posttype ;)
    thanks for adding it to core.

    how about my other question – is it possible to have a sorting like in ajax search results ?

    #1406914

    Hi,

    I do not see an easy way.

    loop-search.php uses the default WP loop in a while statement.

    Would mean you have to resort the search results query first before starting the while loop and then add the “group” changes in the loop.

    You also have to consider pagination (which does not exist in ajax search).

    Best regards,
    Günter

    #1406964

    ok – I thought – inspired by the ajax search results – there would be an easy way to do this.
    so don’t put any work into it – obviously no one else has been interested yet.

    #1407289

    Hi,
    Glad that Günter could clarify this for you, shall we close this then?

    Best regards,
    Mike

    #1413837

    Hi,
    we got a similar question as Guenni007.

    It seems that the search results on the search page are sorted by date. The newest Post is the first.
    We use the search in combination with a WooCommerce-Shop and want to order the results for relevance.
    Is there way to change the order of the results?

    Best regards
    Bernd

    #1413976

    Hi @boehmmedia,

    As already mentioned before: our loop-search.php uses the default WP loop.

    You must hook in the default WP search query and alter this to return the results in the order you need. Maybe these articles helps you:

    https://stackoverflow.com/questions/52317953/change-search-query-wordpress
    https://stackoverflow.com/questions/9468804/make-wordpress-search-only-in-post-title

    But maybe it is a better idea to use a standard WooCommerce extension like

    WooCommerce Product Search

    Best regards,
    Günter

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.