我有一个插件使用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和不删除数据的其余部分我以前保存的是不是在当前子集?