您不必创建帖子来保存数据,您可以使用Settings API
例如,您输入了函数。php:
$copyright = get_option(\'my_them_copyright\');
if (!isset($copyright)){
$copyright = \'Design by: <a href="domain.com">ME</a>\';
update_option(\'my_them_copyright\',$copyright);
}
然后,无论何时您想调用它,都可以使用get\\u option(),如下所示:
$copyright = get_option(\'my_them_copyright\');
echo $copyright;
更新就像我评论的一样,任何帖子/页面都会自动获得永久链接,但你可以做的是注册自己的帖子类型
<?php
add_action(\'init\', \'register_generic_data\');
function register_generic_data()
{
$labels = array(
\'name\' => _x(\'Generic Data\', \'post type general name\'),
\'singular_name\' => _x(\'Generic Data\', \'post type singular name\'),
\'add_new\' => _x(\'Add New\', \'Generic Data\'),
\'add_new_item\' => __(\'Add New Generic Data\'),
\'edit_item\' => __(\'Edit Generic Data\'),
\'new_item\' => __(\'New Generic Data\'),
\'view_item\' => __(\'View Generic Data\'),
\'search_items\' => __(\'Search Generic Data\'),
\'not_found\' => __(\'No Generic Data found\'),
\'not_found_in_trash\' => __(\'No Generic Data found in Trash\'),
\'parent_item_colon\' => \'\'
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => false,
\'exclude_from_search\' => true,
\'show_in_nav_menus\' => false,
\'show_ui\' => true,
\'query_var\' => false,
\'rewrite\' => false,
\'capability_type\' => \'post\',
\'hierarchical\' => true,
\'menu_position\' => 20,
\'supports\' => array(\'title\',\'editor\',\'author\',\'thumbnail\',\'excerpt\',\'trackbacks\',\'custom-fields\',\'comments\',\'revisions\',\'page-attributes\'),
\'taxonomies\' => array(\'category\',\'post_tag\')
);
register_post_type(\'gen_data\',$args);
};?>
现在,如果您仔细看看这一部分:
\'publicly_queryable\' => false,
\'exclude_from_search\' => true,
\'show_in_nav_menus\' => false,
\'query_var\' => false,
\'rewrite\' => false,
\'show_ui\' => true,
您可以看到,我们将帖子类型设置为具有ui,并在管理菜单中显示,但除此之外,它的“none public”。
因此,您可以使用此帖子类型或任何其他需要帖子功能的“通用数据类型”创建您的公文包帖子。