php - pagination doesn't work with custom page on wordpress -
i have problem wordpress. problem pagination in custom page doesn't work searched bunch of answers on google couldn't find right answer problem. works in index.php never works on custom pages. if click number 2 of pagination never go page 2 , staying in page 1 , nothing changed before clicked next page number. here codes problem. hope can fix reading! , page i'm making. http://hongikezer.esy.es/hongik_draw/draw/
first code functions.php second 1 css file third code single-hingik_draw.php custom page
<?php function register_my_menu() { register_nav_menu('header-menu',__('header menu')); } add_action('init','register_my_menu'); /*sidebar enable*/ function register_my_sidebar() { register_sidebar( array(('name')=>__('main sidebar') ) ); } add_action('init','register_my_sidebar'); add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 232, 211); //custom page add_action('init', 'codex_custom_init'); function codex_custom_init(){ // register_post_type( 'hongik_about', array( 'labels' => array('name' => __('about'),'singular_name' => __('about1')), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor','thumnail'), ) ); // test register_post_type( 'hongik_test', array( 'labels' => array('name' => __('test'),'singular_name' => __('test')), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor','thumnail'), ) ); // curri register_post_type( 'hongik_curri', array( 'labels' => array('name' => __('curri'),'singular_name' => __('curri')), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor','thumnail'), ) ); // drawing register_post_type( 'hongik_draw', array( 'labels' => array('name' => __('draws'),'singular_name' => __('draw')), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor','thumnail'), ) ); // blog register_post_type( 'hongik_blog', array( 'labels' => array('name' => __('blogs'),'singular_name' => __('blog')), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor','thumnail'), ) ); flush_rewrite_rules(); } //pagination function wpbeginner_numeric_posts_nav() { if( is_singular() ) return; global $wp_query; /** stop execution if there's 1 page */ 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 ); /** add current page array */ if ( $paged >= 1 ) $links[] = $paged; /** add pages around current page array */ if ( $paged >= 3 ) { $links[] = $paged - 1; $links[] = $paged - 2; } if ( ( $paged + 2 ) <= $max ) { $links[] = $paged + 2; $links[] = $paged + 1; } echo '<div class="navigation"><ul>' . "\n"; /** previous post link */ if ( get_previous_posts_link() ) printf( '<li>%s</li>' . "\n", get_previous_posts_link() ); /** link first page, plus ellipses if necessary */ if ( ! in_array( 1, $links ) ) { $class = 1 == $paged ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' ); if ( ! in_array( 2, $links ) ) echo '<li>…</li>'; } /** link current page, plus 2 pages in either direction if necessary */ sort( $links ); foreach ( (array) $links $link ) { $class = $paged == $link ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link ); } /** link last page, plus ellipses if necessary */ if ( ! in_array( $max, $links ) ) { if ( ! in_array( $max - 1, $links ) ) echo '<li>…</li>' . "\n"; $class = $paged == $max ? ' class="active"' : ''; printf( '<li%s><a href="%s">%s</a></li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max ); } /** next post link */ if ( get_next_posts_link() ) printf( '<li>%s</li>' . "\n", get_next_posts_link() ); echo '</ul></div>' . "\n"; } ?>
/* pagination */ .navigation li a, .navigation li a:hover, .navigation li.active a, .navigation li.disabled { color: #fff; text-decoration:none; } .navigation li { display: inline; } .navigation li a, .navigation li a:hover, .navigation li.active a, .navigation li.disabled { background-color: #6fb7e9; border-radius: 3px; cursor: pointer; padding: 12px; padding: 0.75rem; } .navigation li a:hover, .navigation li.active { background-color: #3c8dc5; }
<?php /*template name: drawing*/ ?> <?php get_header(); ?> <div id="content"> <!--<//?php if (have_posts()): while (have_posts()):the_post();?> <div class="test_box"> <//?php the_post_thumbnail(); ?> </div> <//?php endwhile; endif; ?>--> <!--wp_query--> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args=array( 'post_type'=>'post', 'posts_per_page'=>3, 'paged'=>$paged, ); query_posts($args); $args = array('cat' => 4); $category_posts = new wp_query($args); if($category_posts->have_posts()) : while($category_posts->have_posts()) : $category_posts->the_post(); ?> <div class='test_box'><?php the_post_thumbnail(); ?></div> <?php wp_reset_postdata(); ?> <?php endwhile; endif; ?> <!--//wp_query--> <!--pagination--> <?php wpbeginner_numeric_posts_nav(); ?> <!--//pagination--> </div> <!--<//?php get_sidebar();?>--> <?php get_footer(); ?>
Comments
Post a Comment