分页不适用于wordpress上的自定义页面

时间:2017-07-25 16:47:09

标签: php css wordpress

我的wordpress有问题。问题是我的自定义页面中的分页没有工作我在谷歌搜索了一堆答案,但它找不到我的问题的正确答案。实际上它适用于Index.php但从不适用于自定义页面。如果我点击分页的第2个,它永远不会进入第2页并且只停留在第1页,并且没有任何变化,而不是在我点击下一页数之前。这是我的问题代码。希望我能解决它感谢阅读!这是我正在制作的页面。 http://hongikezer.esy.es/hongik_draw/draw/

第一个代码是functions.php 第二个是css文件 第三个代码是single-hingik_draw.php,这是我的自定义页面



<?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(){
	// About
	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 only 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 to the array */
	if ( $paged >= 1 )
		$links[] = $paged;

	/**	Add the pages around the current page to the 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 to 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 to current page, plus 2 pages in either direction if necessary */
	sort( $links );
	foreach ( (array) $links as $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 to 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";

}





?>
&#13;
/* 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 a {
	background-color: #3C8DC5;
}
&#13;
<?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(); ?>
&#13;
&#13;
&#13;

0 个答案:

没有答案