Search Unleashed 应该会在每次有人创建新帖子时自动将新帖子添加到其索引中。但是,对于我们的任何自定义帖子类型下的帖子,这似乎都不会发生。
我可以使用 SU 的重新索引按钮从仪表板内部手动触发重新索引。但我想使用 cron 将其自动化。
我现在正在尝试设置一个可以通过 cron 运行的脚本。这是我到目前为止所拥有的:
<?php
// Fire up wordpress
include $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php';
/*
* We're calling this function from the plugin folder, inside the content
* directory (as opposed to the admin directory) – so when wp-load is called,
* we're not going to be in the admin section, and we're not going to get access
* to those functions. On the bright side, we also don't have to deal with
* WordPress forcing you to login. Since we still need those admin functions,
* include wp-admin/admin-functions.php. This loads up the admin side and gives
* us access to the admin functions
*/
include $_SERVER['DOCUMENT_ROOT'] . '/wp-admin/admin-functions.php';
?>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript" >
$.noConflict();
jQuery(document).ready(function ($) {
jQuery('#wrapper').Progressor( {
start: jQuery('input[name=reindex]'),
cancel: 'Cancel',
url: '<?php echo admin_url('admin-ajax.php') ?>',
nonce: '<?php echo wp_create_nonce ('searchunleashed-index')?>',
finished: 'Finished!'
});
});
</script>
<?php
?>
但是,它并没有起到作用。有什么我想念的吗?