robmaric
Forum Replies Created
-
Thank you – for some reason the PageView event is now firing on the homepage. I will contact via that form if the problem re-occurs.
Thanks for the reply. How can I share the link privately to you?
Ok thanks very much for the speedy reply.
After months these banners are still showing! Version 6.6.1
Forum: Plugins
In reply to: [Yoast SEO] Text contains 0 wordsI’m also having this issue. It’s causing great inconvenience for a client who writes large articles. When will a fix be released? If it will be a while, how safe is it to roll back to 24.2? 100% safe? Thank you
Thank you so much Mikko – sorry for the delay. Haven’t been able to work on this since last week. I wasn’t going to leave this without at least a thank you (and I have left a 5 star review after your fantastic support and great plugin).
I am now usingrelevanssi_modify_wp_query
to restrict the date to “from” and “to” and it works great. Using your exact snippet on your site. I’m just going to keep things simple and handle all searches (so even without a search term) through Relevanssi as there aren’t really that many searches on this site so I don’t feel it’s worth complicating things beyond that.
I have also usedrelevanssi_modify_wp_query
to limit posts to only ones which have at least one of a list of tags. I’m pretty sure I’m doing it right (filter code below).
Thank you again!// Limit search results to brand tags
add_filter( 'relevanssi_modify_wp_query', 'rlv_limit_to_brand_tags' );
function rlv_limit_to_brand_tags( $query ) {
// Define the tag slugs to filter by
$allowed_tags = isset($_GET['brands']) ? (array) $_GET['brands'] : [];
// If no tags exist, return $query (don't modify)
if (!$allowed_tags) {
return $query;
}
// Modify query to only show posts that have at least one of our brand tags
$tax_query = array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'terms' => $allowed_tags,
'operator' => 'IN',
),
);
$query->set( 'tax_query', $tax_query);
return $query;
}Can I remove Relevanssi from the equation when there’s no search term while still using my same search form and same search results page? I have quite a complex search results template I’ve been making in Bricks builder.
Thanks for the reply! It’s a tech review site. The client wants the user to have the option to search just by choosing a date range and one or more brand tags. I’m not sure how I could achieve this without this approach.
Will I need different approaches for baking in the date range for search term vs no search term? or could eitherrelevanssi_modify_wp_query
orpre_get_posts
achieve this?- This reply was modified 2 months, 2 weeks ago by robmaric.
Thanks for the speedy reply!
Edit: OK I just realised this is related to the site having many posts (12000) and Relevanssi only returning the first 500 by default when there’s no search term entered. It’s a very large old blog site. I am making it only show the latest 2 years by default in my hits filter there as users mostly want recent content. I changed the throttle to pre_option_relevanssi_throttle_limit to 20000 and the issue goes away. Of course this is very demanding so whats the best way to restrict the date range on both a search with a search term and one without? That would be much better than using relevanssi_hits_filter I presume. Most searches will be a limited date range, only rarely a user would need to go back very far. Would this be the most efficient way and would it work for ‘without a search term’ too? https://www.relevanssi.com/knowledge-base/searching-between-dates/ I’m guessing I might need different ways of handling the 2 scenarios.
And what is the best way to get “search without a search term” results to be in reverse order so its the latest posts first? Thank you!
Here are the functions:// Limit to brand tags
add_filter('relevanssi_hits_filter', function($hits) {
// Define the tag slugs to filter by
$allowed_tags = isset($_GET['brands']) ? (array) $_GET['brands'] : [];
// Get the term IDs for the allowed tags
$tag_ids = array_map(function($slug) {
$tag = get_term_by('slug', $slug, 'post_tag');
return $tag ? $tag->term_id : null;
}, $allowed_tags);
$tag_ids = array_filter($tag_ids); // Remove null values
// If no valid tags, return the unfiltered results
if (empty($tag_ids)) {
error_log('No valid tag IDs found for filtering.');
return $hits;
}
// Filter the results to include only posts with the allowed tags
$filtered_hits = [];
foreach ($hits[0] as $post) {
$post_tags = wp_get_post_terms($post->ID, 'post_tag', ['fields' => 'ids']);
if (array_intersect($tag_ids, $post_tags)) {
$filtered_hits[] = $post;
}
}
$hits[0] = $filtered_hits; // Update the filtered results
return $hits;
});
// Limit to last 2 years
add_filter('relevanssi_hits_filter', function($hits) {
// Check if the 'include-old-results' parameter is set
if (isset($_GET['include-old-results']) && $_GET['include-old-results'] === 'yes') {
return $hits; // Skip filtering
}
$filtered_hits = [];
$two_years_ago = strtotime('-2 years'); // Calculate the timestamp for 2 years ago
foreach ($hits[0] as $post) {
// Check if the post's date is within the last two years
$post_date = strtotime($post->post_date); // Convert post_date to a timestamp
if ($post_date >= $two_years_ago) {
$filtered_hits[] = $post;
}
}
$hits[0] = $filtered_hits; // Update the filtered results
return $hits;
});- This reply was modified 2 months, 2 weeks ago by robmaric.
- This reply was modified 2 months, 2 weeks ago by robmaric.
- This reply was modified 2 months, 2 weeks ago by robmaric.
- This reply was modified 2 months, 2 weeks ago by robmaric.
- This reply was modified 2 months, 2 weeks ago by robmaric.
- This reply was modified 2 months, 2 weeks ago by robmaric.
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Can’t get weight settings to have much effectSOLVED: Ok it’s to do with the Bricks Query Loop that’s outputting the search results when I try to make my own Search template in Bricks. If I turn that off and let it use the default WordPress search results they match the back end. Phew.
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Can’t get weight settings to have much effectExtra info: I have enabled Admin Search and I see the tag weights have a big effect there, working great. So it looks to be an issue with the front end which gives totally different results. I am using Bricks builder. I have “Query Bricks data in search results” turned off, also “Enable query sort / filter / live search” is off.
Logging in today, without doing anything, I don’t see the banner showing at all any more. Could it have synchronised automatically? If so it must have worked. Thank you!
Yes it persists after clearing cache.
Thanks for the fast reply. It’s g-mee.com
Ok thanks Nigel. Must not have been updated. Glad to know it’s fixed.