• Resolved tatort

    (@tatort)


    Hi,

    i use Relevansi outside of the searchpage to get similar content. First i use this snippet:

    $query = new WP_Query();
    $similar = get_transient('relevanssi_similar_' . $post->ID);
    if (empty($similar)) {
    	$query->query_vars['s'] = $post->post_title;
    	$query->query_vars['posts_per_page'] = 6;
    	$query->query_vars['operator'] = 'or';
    	relevanssi_do_query($query);
    	//$similar = "<ul>";
    	$similar = "";
    	foreach ($query->posts as $r_post) {
    		if ($r_post->ID == $post->ID) continue;
    		$link = get_permalink($r_post->ID);
    		$title = get_the_title($r_post->ID);
    		$similar .= '<li class="list-group-item"><a href="'.$link.'" title="'.$title.'" >'.$title.'</a></li>';
    	}
    	//$similar .= "</ul>";
    	set_transient('relevanssi_similar_' . $post->ID, $similar, 60 * 60 * 24 * 4);
    }
    echo $similar;

    But partly it comes before the some entries from the internal search not appear in the similar articles.
    Therefore, I hollow the entry using the following code:

    $query = new WP_Query();
    $query->query_vars['s'] = $post->post_title;
    $query->query_vars['posts_per_page'] = 6;
    $query->query_vars['paged'] = 1;
    $query->query_vars['operator'] = 'or';
    relevanssi_do_query($query);
    	$similar = "";
    	foreach ($query->posts as $r_post) {
    		if ($r_post->ID == $post->ID) continue;
    		$link = get_permalink($r_post->ID);
    		$title = get_the_title($r_post->ID);
    		$similar .= '<li class="list-group-item"><a href='.$link.'  title="'.$title.'" >'.$title.'</a></li>';
    	}
    	//$similar .= "</ul>";
    	
    	echo $similar;

    Unfortunately the code $query->query_vars['operator'] = 'or'; does not work here.

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

    (@msaari)

    Yes. Adjusting the operator on the fly is a Premium feature, and it only works in Relevanssi Premium.

    Plugin Author Mikko Saari

    (@msaari)

    But of course there’s always this:

    update_option('relevanssi_implicit_operator', 'OR');

    and once you’re done,

    update_option('relevanssi_implicit_operator', 'AND');

    Thread Starter tatort

    (@tatort)

    Thanks Mikko,

    i buy the Premium Version.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    i buy the Premium Version.

    That’s good but now for pro or commercial product support please contact the author directly on their site.

    https://www.relevanssi.com/

    As the author is aware, commercial products are not supported in these forums. As you are their customer I am sure they will have no problem supporting you there.

    Plugin Author Mikko Saari

    (@msaari)

    Jan, Tatort wasn’t a customer when he asked this question. I also provided a solution that only applies to the free version.

    As this thread is already marked resolved, I’m not sure what the need for policing is in this case. I very much prefer handling the Premium customer support on different channels, and will do my best to redirect Premium customers to appropriate channels, but this was all about the free version.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[‘operator’] = ‘or’; outsite searchpage (Similar)’ is closed to new replies.