syrupcore
Forum Replies Created
-
Forum: Plugins
In reply to: [Jetpack - WP Security, Backup, Speed, & Growth] Jetpack Comments + Akismet?Clarifies them both perfectly. Thank you for very much taking the time.
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Indexing 1-3 Character Custom FieldsCheers, Mikko. Yep, having the minimum set to “1” is working fine in practice.
There’s no easy solution to make the minimum length apply to just one thing, because the same minimum length is used in indexing and in searching.
Makes sense. Indexing takes roughly the same time regardless of minimum. When searching for one or two character phrases though, it takes quite a bit longer but that is sort of expected (though I dunno if regular users will be expecting it!). Almost want to say the length doubles with each character removed but I haven’t measured it or anything.
Forum: Plugins
In reply to: [Relevanssi - A Better Search] No search results – search.php has queryTry replacing:
$search_results = new WP_Query( array( 's' => $s, 'posts_per_page' => -1 ) ); $total = $search_results->post_count;
with
$total = $wp_query->found_posts;
instead of instantiating a new WP_Query. Think that’s basically wiping out relevanssi.
Also note
$wp_query->found_posts
will give you the total results for the query while$wp_query->post_count
will only return how many posts objects were returned for the current view. That is, you may have 40 total results for the termred
but if you have it set to display 10 results per page,post_count
will be10
whilefound_posts
will be40
. For normal WP searches, the code you have would be fine due to the -1 but Relevanssi doesn’t work with posts_per_page.Forum: Plugins
In reply to: [Relevanssi - A Better Search] Feature SuggestionYou can use
relevanssi_match
filter for this.See the second example on this page: https://www.relevanssi.com/knowledge-base/relevanssi-match/
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Include Author result in searchDo you mean including the author of each search result on the search results page? That would depend on your
search.php
set up. If so, you can just include author template tags within your loop.Forum: Plugins
In reply to: [Relevanssi - A Better Search] Features possible using this pluginAs far as a Google Maps search, you can just do that with Javascript within your search results template. Probably easiest to include the script block directly within the results template (or included template part) because then you’ll have access to the searched term.
Using Google’s example code, replace
performSearch().request{}.keyword
(set to “best view” in the example) with<?php the_search_query(); ?>
. There are other ways to use the maps API for searching, depending on what you want to do, but presuming you’ve including the HTML and API JS properly, that orta ‘just work’. It will appear a little after the local results appear but gmaps searches are blazing fast on the whole.Forum: Plugins
In reply to: [Relevanssi - A Better Search] Features possible using this pluginI’ve been thinking about building a keyword suggestion UI on top of Relevanssi. Haven’t started but here’s what I’m thinking in case you want to give it a go @world2cycle.
- Polling the wp_relevanssi_log table, pull any log entry that has more than, say, 5 in the
hits
column. Create a JS object with it (keeping the hits number). - Make a JS array from that object that is (somehow) sorted by 1) number of hits and 2) number of occurrences within the log. That would make the list sorted by both usefulness (# of hits) and popularity (# of occurrences).
- Use something like Awesomeplete/Typeahead/whateverlibrary to actually offer the suggestions from the JS object.
- Can also pull post titles, tags, categories, etc to put into the same JS object the autocomplete library will pull from. Typeahead actually has some create facilities for using multiple JS objects and presenting them separately within the suggestions so you could, for example, have keywords, posts and tags all separated.
I don’t think it would actually be all that hard I just haven’t found the time to try it out.
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Different Search for Stopwords?Thank you, Mikko!
Forum: Plugins
In reply to: [Relevanssi - A Better Search] Different Search for Stopwords?Aha! in
/lib/search.php
, there is a variable called$remove_stopwords
which is hard coded totrue
. A couple of lines later, this happens:$terms = relevanssi_tokenize($q, $remove_stopwords);
And since the second argument for
relevanssi_tokenize
is$remove_stops
, the stopwords never get through. When I set “$remove_stopwords” tofalse
, all works as expected. Guess that would need to be somehow tied into the possible filter?Forum: Plugins
In reply to: [Relevanssi - A Better Search] Different Search for Stopwords?Thanks for this, Mikko. I changed the line in /lib/indexing.php and reindexed. Good news is: it indexed the stopwords in titles (I checked the wp_relevanssi table via mysql directly). Unfortunately, when I search for one of the stopwords I know it indexed… I get no results. Do I need to change something else?
Forum: Plugins
In reply to: [Relevanssi - A Better Search] ACF Relationship fieldThank you both! Helped me quite a bit. I’m using CMB2’s “Related Posts Field” which stores a single ‘related’ post ID. Here’s what worked for me:
add_filter('relevanssi_content_to_index', 'MY_include_related_content', 10, 2); add_filter('relevanssi_excerpt_content', 'MY_include_related_content', 10, 2); function MY_include_related_content($content, $post) { $related = get_post_meta( $post->ID, 'custom_field_with_post_id', true ); if (is_numeric($related)) { $content .= apply_filters('the_content', get_post_field('post_content', $related)); } return $content; }
@mikko also posted this over on the blog post that lead me.
Forum: Plugins
In reply to: [CMB2] Before/Before Row.. on a Group field?I’m in!
Forum: Plugins
In reply to: [CMB2] Before/Before Row.. on a Group field?Thanks very much, Michael. Totally missed that hook. I saw https://github.com/WebDevStudios/CMB2/wiki/Tips-&-Tricks#using-the-dynamic-beforeafter-form-hooks at some point but didn’t put 2 and 2 together. Using that along with separated meta boxes (I was cramming it all into one giant box) is what I c/should do.
I guess this is a feature request then. ?? To whatever extent is reasonable, have feature parity for group fields. I understand enough to know that they’re very different beasts and feature parity isn’t possible (or even needed for parts of it) but it would be sweet to have these sorts of row manipulators available to them if possible.
Would also be handy to have a single CMB2 wiki page with all of the available CMB2 hooks listed on it. A sort of one-stop-shop to look in when you want to augment the behavior of CMB2. I browsed the wiki and searched around the internets before asking this here but I don’t think I know/knew enough to plop in the right keywords to have that appear.
Anyway, thanks again. Marking as resolved.
Forum: Plugins
In reply to: [CMB2] Before/Before Row.. on a Group field?Thanks, Michael.
Basic test code follows. In this example I tried basically all options on both places I could think to try them. I’m tried reading through the source to see if this was even possible but TBH, got a little (ok, a lot) lost.
My use case is: this group contains a set of fields with 4 different fields. I want to have some introductory text in a particular set of styles before the group starts. I found a way around that by including a “title” field which does support all of the before/after stuff. I’m also using CSS to cheat and make the group look like a separate set of meta boxes. Without before and after, that requires some fairly fragile CSS selectors instead of generic classes.
On this same note, it would be lovely if group fields also supported
row_classes
.$local_actions_group_field = $coa_cmb->add_field( array( 'id' => $prefix . 'local_conservation_actions_and_plans', 'type' => 'group', 'description' => __( 'Local Conservation Action or Plans', 'odfw' ), 'before_row' => '<p>Testing <b>"before_row"</b> parameter</p>', 'before' => '<p>Testing <b>"before"</b> parameter</p>', 'before_field' => '<p>Testing <b>"before_field"</b> parameter</p>', 'after_field' => '<p>Testing <b>"after_field"</b> parameter</p>', 'after' => '<p>Testing <b>"after"</b> parameter</p>', 'after_row' => '<p>Testing <b>"after_row"</b> parameter</p>', 'options' => array( 'group_title' => __( 'Action or Plan {#}', 'odfw' ), 'add_button' => __( 'Add another Local Conservation Action or Plan', 'odfw' ), 'remove_button' => __( 'Remove this entry', 'odfw' ), 'sortable' => true, // beta 'before_row' => '<p>Options Testing <b>"before_row"</b> parameter</p>', 'before' => '<p>Options Testing <b>"before"</b> parameter</p>', 'before_field' => '<p>Options Testing <b>"before_field"</b> parameter</p>', 'after_field' => '<p>Options Testing <b>"after_field"</b> parameter</p>', 'after' => '<p>Options Testing <b>"after"</b> parameter</p>', 'after_row' => '<p>Options Testing <b>"after_row"</b> parameter</p>', ) ));
Forum: Plugins
In reply to: [Text Hover] Matching within HTML TagsWell, I tried this and it seems to be working. I took out the negative look aheads and added
>
and<
to either side main capture. In some brief testing it seems to be fine but my Regex Fu is weak enough that I’m not entirely sure what problem I’ve just created! Can anyone tell me?Here’s the original:
$regex = "(?!<.*?)([\s\'\"\.\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\(\[\{])($old_text)([\s\'\"\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\?\!\.\,\-\+\]\)\}])(?![^<>]*?>)";
Here’s the one I’m using:
$regex = "([\s\>\'\"\.\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\(\[\{])($old_text)([\s\<\'\"\x98\x99\x9c\x9d\xCB\x9C\xE2\x84\xA2\xC5\x93\xEF\xBF\xBD\?\!\.\,\-\+\]\)\}])";
- Polling the wp_relevanssi_log table, pull any log entry that has more than, say, 5 in the