• Resolved wissam6

    (@wissam6)


    hi,
    if i put the search in a widget (like a footer) the search works, but it i put it inside my page (i am using Divi theme) then it doesn’t. after many search i found that the query triggered is different between these 2:

    for the first one (which it works):

    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    FROM wp7u_relevanssi AS relevanssi
    WHERE relevanssi.term = 'داود'
    AND (relevanssi.doc IN (
    SELECT DISTINCT(tr.object_id)
    FROM wp7u_term_relationships AS tr
    WHERE tr.term_taxonomy_id IN (18))
    OR (relevanssi.doc = -1))
    AND relevanssi.doc NOT IN (211,212,213,214,215,216,217,218,219)
    ORDER BY tf DESC
    LIMIT 500

    for the second one:

    SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 5 + relevanssi.content * 1 + relevanssi.comment * 0.75 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 0.75 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf
    FROM wp7u_relevanssi AS relevanssi
    WHERE relevanssi.term = 'داود'
    AND (relevanssi.doc IN (
    SELECT DISTINCT(tr.object_id)
    FROM wp7u_term_relationships AS tr
    WHERE tr.term_taxonomy_id IN (18))
    OR (relevanssi.doc = -1))
    AND relevanssi.doc NOT IN (211,212,213,214,215,216,217,218,219)
    AND (relevanssi.doc IN (SELECT DISTINCT(posts.ID)
    FROM wp7u_posts AS posts
    WHERE posts.post_type IN ('page', 'post') ) )
    ORDER BY tf DESC
    LIMIT 500
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter wissam6

    (@wissam6)

    it seems there is a difference if we put the search in a widget or inside a page! is it true?

    Plugin Author Mikko Saari

    (@msaari)

    The parameters are the same, except in the second one the search is restricted to pages and posts. If the content you’re looking for is not pages or posts, then yes, the second search won’t find it. If you’re looking for posts and pages, the queries should be practically equivalent.

    The widgets are coming from WP or your theme, and Relevanssi has nothing to do with them, so I can’t comment on how they work.

    Thread Starter wissam6

    (@wissam6)

    the content i am looking for is in project, so that’s why.
    is there any way to use it in a widget and the widget is placed inside the page, but not as sidebar?

    Plugin Author Mikko Saari

    (@msaari)

    You may check your theme settings to see if there’s a search type filtering somewhere in there. If that doesn’t help, then adding this to your child theme functions.php should help:

    add_filter( 'relevanssi_modify_wp_query', 'rlv_post_types' );
    function rlv_post_types( $query ) {
      $query->set( 'post_types', 'post,page,project' );
      return $query;
    }

    where post,page,project is a list of post types you want the search to include. This will override whatever is set in the search widget.

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

The topic ‘search is working in widget not in page’ is closed to new replies.