0

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(); ?>
5
  • Do you have debugging information that you could add?
    – s_ha_dum
    Feb 20, 2013 at 20:01
  • Which information would you like? Feb 20, 2013 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, 2013 at 20:23
  • I am sure. But I'm not 100% sure how to enable debugging. Feb 21, 2013 at 16:41
  • debugging information
    – s_ha_dum
    Feb 21, 2013 at 16:55

1 Answer 1

1

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' )

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.