0

This function output :

<<NEXT [SELECT] PREV>>

i need this :

<option value="link/page1">Page 1</option>
<option value="link/page2">Page 2</option>

how do I convert this function to this?

function yorumlariSayfala ( $args = array() ) {
global $wp_rewrite;

if ( ! is_singular() )
    return;

$page = get_query_var('cpage');
if ( !$page )
    $page = 1;
$max_page = get_comment_pages_count();
$defaults = array(
    'base' => add_query_arg( 'cpage', '%#%' ),
    'format' => '',
    'total' => $max_page,
    'current' => $page,
    'echo' => true,
);
if ( $wp_rewrite->using_permalinks() )
    $defaults['base'] = user_trailingslashit(trailingslashit(get_permalink()) . $wp_rewrite->comments_pagination_base . '-%#%', 'commentpaged');

$args = wp_parse_args( $args, $defaults );
$page_links = paginate_links( $args );

if ( $args['echo'] )
    echo $page_links;
else
    return $page_links;
}

1 Answer 1

1

Here is the snippet for archive navigation with previous and next link along with the select dopwdown. Select will contain the list of all pages and page url as value of option. onChange is used to redirect page when select option is changed. You can use following code and modify as per your need.

function wpso_custom_archive_navigation() {
    global $wp_query;
    if ( is_singular() ) {
        return;
    }
    if ( $wp_query->max_num_pages <= 1 ) {
        return;
    }
    $paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
    $max = intval( $wp_query->max_num_pages );

    // Previous link.
    if ( get_previous_posts_link() ) {
        printf( '%s', get_previous_posts_link( 'Previous' ) );
    }

    echo '<select onChange="window.document.location.href=this.options[this.selectedIndex].value;">';
    for ( $i = 1; $i <= $max ; $i++ ) {
        echo '<option value="' . esc_url( get_pagenum_link( $i ) ) . '" ' . selected( $i, $paged ) . '>';
        echo 'Page ' . $i;
        echo '</option>';
    }
    echo '</select>';

    // Next link.
    if ( get_next_posts_link() ) {
        printf( '%s', get_next_posts_link( 'Next' ) );
    }
}
2
  • I tried to modify it and I failed. :( Commented Jun 28, 2019 at 15:19
  • What happened after you called this function? Commented Jul 2, 2019 at 8:48

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.