• Resolved CeeWP

    (@ceewp)


    Hi Mikko;
    I’am using wp_insert_post function for adding new posts. But Relevanssi is not triggered. I can not solve this problem.
    Would it be correct to use this code in wp cron?
    relevanssi_build_index(true);

    (I have a big database)

    Thanks for this great plugin.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    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 7 years, 1 month ago by CeeWP.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Relevanssi is not triggered when using “wp_insert_post”’ is closed to new replies.