Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a function which allows users to choose between pagination and next/previous links. In fact, I was provided the function on this site. I tested it today and it suddenly isn't working. I can't figure out the cause of this sudden interruption.

It seems that the code will work if I choose the option I want, switch themes, save, then switch back! Absolutely no idea what is going on.

In functions.php:

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

    if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next' ) : 
        // the block for next-prev navigation
        echo '<div class="left">';
        next_posts_link('Older');
        echo '</div>';
        echo '<div class="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
            )
        ); 
    endif; 
}

In my options panel:

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"), 

In index.php:

<?php my_theme_navigation(); ?>
share|improve this question
    
Do you have debugging information that you could add? –  s_ha_dum Feb 20 '13 at 20:01
    
Which information would you like? –  AndrettiMilas Feb 20 '13 at 20:19
    
Anything you have. Follow the link. If you enable debugging, load that page and something pops up it might be relevant. Also, server logs if relevant. Are you sure you didn't do something just before this happened? –  s_ha_dum Feb 20 '13 at 20:23
    
I am sure. But I'm not 100% sure how to enable debugging. –  AndrettiMilas Feb 21 '13 at 16:41
    
debugging information –  s_ha_dum Feb 21 '13 at 16:55

1 Answer 1

up vote 1 down vote accepted

Here is your problem:

"options" => array("Next/Previous Links", "Pagination"), 
"std" => "Next"

Your valid options don't match your default.

Change this:

"std" => "Next"

...to this:

"std" => "Next/Previous Links"

Then, in your function call, change this:

if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next' )

...to this:

if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next/Previous Links' )
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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