Define big. If you click “Build index” on the Relevanssi settings page, are you able to build the whole index on one go?
You may have a wider issue here, because wp_insert_post() should definitely trigger Relevanssi: it’s the last thing it does, firing the wp_insert_post action hook.
But instead of rebuilding the whole index, you can run relevanssi_insert_edit($post_id) with the post ID of the inserted post to index just that one post.
Thread Starter
CeeWP
(@ceewp)
Hi Mikko;
I create custom plugin for adding posts, tags and custom fields to WordPress. I tried trigger to Relevanssi but my previous methods did not work. Your methot is works!
Before; I got an error of relevanssi_insert_edit() function was not found. This error is due to plugin ordering. But I solved this with a plugin order function.
function this_plugin_last() {
$wp_path_to_this_file = preg_replace('/(.*)plugins\/(.*)$/', WP_PLUGIN_DIR."/$2", __FILE__);
$this_plugin = plugin_basename(trim($wp_path_to_this_file));
$active_plugins = get_option('active_plugins');
$this_plugin_key = array_search($this_plugin, $active_plugins);
array_splice($active_plugins, $this_plugin_key, 1);
array_push($active_plugins, $this_plugin);
update_option('active_plugins', $active_plugins);
}
add_action("activated_plugin", "this_plugin_last");
https://gist.github.com/bappi-d-great/26808240df88dd1fc3fe
The “relevanssi_insert_edit” function works perfectly now
if (function_exists('relevanssi_insert_edit')) {
relevanssi_insert_edit($new_ID);
}
Thank you for your detailed reply. Your plug-in works very well. Please continue to develop and supporting.
Have a good weekend.
-
This reply was modified 8 years, 6 months ago by
CeeWP.