我有一個插件使用WordPress的選項 - 它保存每個頁面和帖子的數據,用ID標記,我可以在前端拉出並顯示自定義數據該帖子或頁面。WordPress的選項表刪除條目子集時的所有值
例如,我可以爲每個帖子輸入自定義數據1-25,成功保存到Options.php,轉到頁面2,在那裏我看到帖子條目26-50,併爲這些條目保存數據...但保存數據爲26-50溼巾我剛纔保存的條目1-25數據和51- X
我正在使用的分頁代碼是一個自定義的片段:
$how_many_results = 25;
$post_args = array('numberposts' => -1, 'posts_per_page' => $how_many_results, 'orderby' => 'title', 'order' => 'ASC', 'paged' => $paged,'post_type' => 'post')
$posts_query = new WP_Query($post_args);
$mnposts = $posts_query->max_num_pages;
$big = 999999999999;
$posts_pagination = paginate_links(array(
'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
'current' => max(1, $paged),
'total' => $mnposts,
'end_size' => 1,
'mid_size' => 1,
'prev_next' => True,
'prev_text' => __('Prev','cust_dataset'),
'next_text' => __('Next','cust_dataset'),
'type' => 'list'
));
echo (!isset($posts_pagination))?'<span>'.__('All posts displayed','cust_dataset').'</span>':$posts_pagination;
這是HTML格式:
<form method="post" action="options.php">
<?php
settings_fields('cust_options_post');
$cust_posts = get_option('cust_settings_post');
$cust_name = 'cust_name_'.get_the_ID();
$cust_name_set = (isset($cust_posts[$cust_name]))?$cust_posts[$cust_name]:'';
$option .= '<input type="hidden" name="cust_settings_post['.get_permalink().']" id="cust_settings_post['.get_permalink().']" value="'.$red_url.'" />';
$option .= '<strong>' . get_the_title() . '</strong> (<em><a href="' . get_admin_url() . 'post.php?post=' . get_the_ID() . '&action=edit">edit</a></em>)';
$option .= '<br />' . get_permalink() . ' (<em><a href="' . get_permalink() . '">view</a></em>)';
$option .= '<input type="text" name="cust_settings_post['.$cust_name.']" id="cust_settings_post['.$cust_name.']" value="'.$cust_name_set.'" />';
?>
<?php echo $option; ?>
<input type="submit" />
</form>
問題是,分頁只能一次拉出25,Wordpress在每個表單提交中重新保存整個選項塊,即使它只是25個條目的子集。如果我有100頁,這不會成爲問題,但是我在一個擁有超過30,000個帖子的網站上運行它......並且我無法一次處理30,000個選項數據集,導致服務器停止運行。
我的問題是:怎樣的數據子集保存到Options.php和不刪除數據的其餘部分我以前保存的是不是在當前子集?