• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Need help with post pagination php code

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

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

This topic is: not resolved

Tagged: drop down, genesis, pagination

  • This topic has 1 reply, 1 voice, and was last updated 10 years ago by Afaq.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 9, 2013 at 5:01 am #61476
    Afaq
    Member

    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.

    September 22, 2013 at 1:12 am #63731
    Afaq
    Member

    Anyone?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble