Step 1: Register the setting in the customizer
将此添加到
wptuts_theme_customizer()
函数,该函数将注册新的“分页”部分以及“分页样式”设置:
/* Section: Pagination */
$wp_customize->add_section( \'themeslug_pagination\', array(
\'title\' => __( \'Pagination\', \'themeslug\' ),
) );
$wp_customize->add_setting( \'pagination_style\', array(
\'default\' => \'next-previous-links\',
) );
$wp_customize->add_control( \'pagination_style\', array(
\'label\' => __( \'Pagination Style\', \'themeslug\' ),
\'section\' => \'themeslug_pagination\',
\'type\' => \'radio\',
\'choices\' => array(
\'next-previous-links\' => __( \'Next/Previous Links\', \'themeslug\' ),
\'numbered\' => __( \'Numbered\', \'themeslug\' ),
),
) );
Step 2: Modify the pagination function to work with the customizer setting
修改您的
my_theme_navigation()
功能如下:
BEFORE:
if( get_option( $shortname . \'_next_prev_or_paginate\' ) == \'Next/Previous Links\' ) :
AFTER:
if ( \'next-previous-links\' == get_theme_mod( \'pagination_style\' ) ) :
注意,因为主题mod特定于当前活动的主题,所以不需要在它们前面加前缀{$themename}_
, 这是多余的。
这是您的原始代码,添加了我的修改:
主题定制器代码:http://pastebin.com/eqjmJU7t分页功能:http://pastebin.com/GLUx3RTr