Dynamic Content with theme pro
-
I would like to use Relevanssi on one of my pages because it also searches shortcodes.
The theme pro (from ThemeCo) which I mainly use generates more dynamic content using custom shortcodes like {{dc:post:title}}, which displays the title of the post.
Would it be possible to search the complete parsed content?
Also, the search behaves strangely when you are logged in or not. It even redirects to the home page instead of showing “No search term found”.
-
No, it didnt’t fire either, even if i deactivate all other plugins!
Then Relevanssi indexing is not happening.
How are you testing this? Where is the code, how are you running the indexing, how are you testing how the filters work?
Relevanssi creates an index, and it also indexes some words for the page I tested with the Relevanssi debugger as well.
The filter hooks I tested with my own error log function, which simply writes the text I pass to a log file. This should happen in any case as soon as this hook is called.
function bhstein_error_log ($path, $log) { file_put_contents ("error.log", current_time ("[Y-m-d H:i:s] ") . "(" . $path . "): ". $log . "\n", FILE_APPEND);}`
And the call:
add_filter( 'relevanssi_post_content', 'rlv_apply_the_content' ); function rlv_apply_the_content( $content ) { $output = apply_filters( 'the_content', $content ); bhstein_error_log ("relevansi", "content: " . $content . " | filter: " . $output); return $output; // return apply_filters( 'the_content', $content ); }And the filter is defined in code that is executed when Relevanssi does the indexing?
You can try modifying the
relevanssi_index_content()inlib/indexing.phpdirectly, try applying thethe_contentfilters there to see whether that works or not.Yes, that was the bull’s eye.
After I called the “the_content” filter directly, all keywords were now found! But it still does not explain why the relevanssi_post_content filter function were not triggered!
// $contents = apply_filters( 'relevanssi_post_content', $post_object->post_content, $post_object ); $contents = apply_filters( 'the_content', $post_object->post_content);And by the way, maybe you could use this filter for output the search result? Because i got this shortcodes in the excerpt highlight search results too.
the_contentis used when Relevanssi generates the excerpts (you can see for yourself inrelevanssi_do_excerpt()in /lib/excerpts-highlights.php).You read my post before, about the correct indexing with the filter?
And could it be that the Name of 1. User (of course Admin) is filtered out by the search?
Yes, I read your post. I’m not sure what you mean with that.
Is “admin” in the stop word list? If so, it is filtered, but otherwise it shouldn’t be.
Ok, first question: what could it be that relevanssi_post_content filter didn’t fire?
Second question: No, i’ve removed all stopwords and my name is indexed on the imprint page. If i search for it while i’m logged in i found all related posts. If i’m logged out, the search redirect to the start page without showing anything, not even “no search results found”.
But i found the reason now: It’s the ultimate_member plugin that prevents this. Maybe a bug?I don’t really have an answer to your question. If the content from a post is indexed, that filter hook must fire. Are you sure the problem is that the filter hook does not fire? Can the problem be your filter function? The most obvious explanation would be that the filter function is not defined by the time the filter is applied.
As far as I can tell, there should be no problems between Relevanssi and Ultimate Member. The only thing I have in my notes is a method to make the permalinks use the Ultimate Member URLs instead of the default URLs for users, and that does not apply in your case anyway.
Are you using Ultimate Member to somehow restrict access to posts?
Yes i have some pages restricted with ultimate member, but of course not the imprint page. But i will contact their support about this.
About the hook, it fires only if i edit a page directly, after hitting safe, the hook work. But it didn’t fire when using the index all button on the general relevanssi setting page.
I’m sorry, but I have no idea why it’s not working as expected, and I can’t really tell without closer look at your site specifically.
If took a second look on the relevanssi_index_content function in your /lib/indexing.php
The relevanssi_index_content function is only called if i edit and save a post directly, then the hook works of course too! The function is NOT called during the rebuild of the whole index! I’ve checked this several times.
I unfortunately don’t have any way of telling why that is the case on your site.
To debug this, see if
relevanssi_index_doc()runs for all posts when building the index. If it does, then see if the function gets through all the possible early exits, ie. all parts where there’s areturnin the function. If it’s not reaching therelevanssi_index_content(), it must be exiting in some earlier spot.
The topic ‘Dynamic Content with theme pro’ is closed to new replies.