With the native Theme Customization API it makes no sense to have an independent options panel. So how do I implement my code (below) into the Theme Customizer?

Here is the code for my Theme Customizer: code here

In my options panel I allow users to select between Next/Previous Links in archives or pagination, the code looks like this:

array( "name" => "Paginate or next/previous links?",
"desc" => "Choose your option",
"id" => $shortname."_next_prev_or_paginate",
"type" => "select",
"options" => array("Next/Previous Links", "Pagination"),
"std" => "Next/Previous Links"),

Here is the function that makes it work:

// Pagination
function my_theme_navigation() {
    global $shortname;

    if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next/Previous Links' ) :
    // the block for next-prev navigation
    echo '<div class="button left">';
    echo '</div>';
    echo '<div class="button right">';
    previous_posts_link ('Newer');
    echo '</div>'; else :
    // the block for pagination
    global $wp_query;
    $big = 999999999;
    // need an unlikely integer
    echo paginate_links(            array(                'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),                'format' => '?paged=%#%','end_size'     => 1,'mid_size'     => 2,                'current' => max( 1, get_query_var('paged') ),                 'total' => $wp_query->max_num_pages            )        );

I then simply call it using this:

<?php my_theme_navigation(); ?>
  • Hi, are you still looking for a solution? If not, please mark the answer as "accepted". Thanks! Aug 15, 2014 at 15:52

1 Answer 1


Step 1: Register the setting in the customizer

Add this to your wptuts_theme_customizer() function, which will register a new "Pagination" section, as well as a "Pagination Style" setting:

/* 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

Modify your my_theme_navigation() function like this:

if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next/Previous Links' ) :

if ( 'next-previous-links' == get_theme_mod( 'pagination_style' ) ) :

Note that because theme mods are specific to the currently active theme, you don't need to prefix them with {$themename}_, which would be redundant.

Here is your original code, with my modifications added:

  • Hi there, just wondering if you forgot to mark my answer as "accepted", or whether it's working for you or not. :-) Aug 15, 2014 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.