second – i have inline-php in may content. relevansi only indexes the code, but not the parsed content. any idea for a filter where to execute to code that relevansi indexes it?
thanks <3
Post content is passed through relevanssi_post_content
filter before Relevanssi sees it. Add a function to that filter that parses your PHP content to make it visible to Relevanssi. For further details on the filter, see lib/indexing.php.
For your first problem, relevanssi_excerpt
might be the filter you need.
thanks 🙂
for the first question i found http://wordpress.org/support/topic/hide-picture-caption-in-results what works.
second question is solved with relevanssi_post_content
.
but i found out something strange:
when searching for “wish” non of my inline-php documents are found (but others). when searching “blue-wish” 4 of 6 with inline php are shown (2 missing), marking “wish” and the only with “blue-wish” (document title is “wish”) is shown as second on in search-results.
why? am i missing something?
Are you using fuzzy search? That might explain it. Try different settings of the fuzzy search option and see what happens.
tryed all fuzzy options – no change. the title was solved by putting up the weight.
adding to the filter return “dummy_search_term”.time() – all my pages are found when searching. BUT when looking in sql database time() is always the same. so my inline-php is(?) only executed once [checked it with a document with 3x php in it] – same as time().
hmmm…
Well, yes, when you use relevanssi_post_content
to parse the inline code, it is executed once: when the post is indexed. So it’s a static solution, not dynamic. Changes in the PHP code results are not noticed, until the document is indexed again. The code is not parsed during searching – that would be practically impossible.
the ‘preg_replace_callback’ for inline-php is working fine when one page is parsed by wp. is ‘relevanssi_post_content’ called once for all indexed pages (so time() is always the same) or everytime new content is added to
search index?
i don’t want a dynamic index, i’m just wondering, why the ‘preg_replace_callback’ is only fired once for only one document in ‘relevanssi_post_content’. the regex is working fine.
again: not “dynamic” (changing every time), but in 4 document with inline-php “blabla” only one document is found when searching “blabla”.
that confuses me :/
relevanssi_post_content
filter is fired once for each post that is indexed, whenever that post is indexed. So, if you click “Build index”, the filter should be triggered once for every post in your database.
add_filter('relevanssi_post_content', 'rpc_test', 10, 2);
function rpc_test($content, $post) {
echo $post->ID . "<br>";
}
should echo out the post ID of every post in your database when you build the index. Does it?