Need help with post pagination php code

Community Forums Forums General Discussion Need help with post pagination php code

This topic is: not resolved

This topic contains 1 reply, has 1 voice, and was last updated by  Afaq 1 year, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #61476

    Afaq
    Participant
    Post count: 2

    I am moving my site to Genesis and I am using the stock Genesis look as a child theme with a few changes. One of the changes is that I want to use a drop down menu for post pagination; instead of the simple numbering that shows up on stock genesis.

    In my previous theme, this code was being used for the drop down menu and it was working fine but I implemented the same code on Genesis and it isnt working the way it should. The drop down doesnt show the current active page of the post, instead it keeps on showing the first page.

    //*Pagination Drop Down
    function wp_link_pages_dp($args = '',$permalink="",$selectedpage=1) {
      $defaults = array(
    		'before' => '<select class="input-box-medium" onchange="window.location=this.value;">', 
            'after' => '</select>',
            'link_before' => '', 
            'link_after' => '',
            'echo' => 1
        );
        $r = wp_parse_args( $args, $defaults );
        extract( $r, EXTR_SKIP );
        global $page, $numpages, $multipage, $more, $pagenow, $pages;
        $output = '';
        if ( $multipage ) {
            $output .= $before;
            for ( $i = 1; $i < ($numpages+1); $i = $i + 1 ) {
                $part_content = $pages[$i-1];
                $has_part_title = strpos( $part_content, '<!--pagetitle:' );
                if( 0 === $has_part_title ) {
                    $end = strpos( $part_content, '-->' );
                    $title = trim( str_replace( '<!--pagetitle:', '', substr( $part_content, 0, $end ) ) );
                }
                $output .= ' ';
                if ( ($i != $page) || ((!$more) && ($page==1)) ) {
                    $output .= _wp_link_page($i);
                }
                $title = isset( $title ) && ( strlen( $title ) > 0 ) ? $title : 'Introduction';
                if($selectedpage==$i){$sel="selected";}else{$sel="";}
    			$output .= '<option value="'.$permalink.'?page='.$i.'" '.$sel.'>'.$link_before . $i.". ".$title . $link_after.'</option>';
                if ( ($i != $page) || ((!$more) && ($page==1)) )
                    $output .= '</option>';
            }
            $output .= $after;
        }
        if ( $echo )
    		echo $output;
        return $output;
    }

    Can anyone please spot the issue?

    Thanks.

    #63731

    Afaq
    Participant
    Post count: 2

    Anyone?

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.