<?php
/*
Template Name: All Blog Post Custom Template
*/
?>
<?php
/**`enter code here`
* @author madars.bitenieks
* @copyright 2013
*/
ini_set('display_error',1);
get_header();
$page_idd = get_the_ID();
global $post;
//print_r($_GET);exit;
$mt_comment=get_post_meta($post->ID, "madza_comment", true);
$mt_layout = get_post_meta($post->ID, "layout_positions", true);
$mt_float_layout = "";
$mt_float_sidebar = "";
if ($mt_layout == "left") {
$mt_float_layout = "floatright";
$mt_float_sidebar = "floatleft";
}
$more = 0;
?>
<div class="row">
<div class="span<?php if ($mt_layout != "full") { echo "8 "; } else { echo "12 "; } echo $mt_float_layout; ?> ">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php the_content( __( '<div class="reed_more">Reed More »</div><div></div>', 'madza_translate' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'madza_translate' ), 'after' => '</div>' ) ); ?>
<div class="clear"></div>
</div><!--END POST -->
<?php if($mt_comment=='Yes'){ comments_template( '', true ); }?>
<?php endwhile; wp_reset_query(); ?>
</div>
<!-- code for showing all blog post -->
<div class="rpwe-block" style="">
<ul class="rpwe-ul">
<?php
$the_query = new WP_Query($args);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
set_query_var('page',$paged);
$the_query = new WP_Query( array(
'post_type' => 'blog',
'posts_per_page' => 2,
'orderby'=> 'menu_order',
'paged' => $paged
) );
?>
<?php if ($the_query->have_posts()) : ?>
<?php while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li class="rpwe-clearfix">
<a href="<?php the_permalink() ?>">
<?php
add_image_size('custom-size', 180, 150);
the_post_thumbnail('thumbnail');
?>
<h3 class="rpwe-title"><?php the_title(); ?></h3>
</a>
<span class="rpwe-time published"><?php echo get_the_date(); ?></span>
<div class="rpwe-summary">
<?php echo substr(get_the_content(), 0, 100) . "..."; ?>
<a href="<?php the_permalink() ?>"><p>Read More</p></a>
</div>
<?php
endwhile;
?>
<div class="nav-previous alignleft"><?php previous_posts_link('« Newer posts');?></div>
<div class="nav-next alignright"><?php next_posts_link( 'Older posts »', $the_query->max_num_pages ); ?></div>
<?php wp_reset_postdata(); ?>
<?php else :
?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
</ul>
</div>
<?php if ($mt_layout != "full") { ?>
<div class="span4 <?php echo $mt_float_sidebar; ?> "><?php if( !($page_idd == 17169 or $page_idd == 17170) ){get_sidebar();} ?></div>
<?php } ?>
</div>
<?php get_footer(); ?>
我使用CPT(自定义帖子类型)插件创建了名为Bolg的自定义帖子类型。并且我将page.php内容复制到名为blog-page.php的新文件中,然后复制我的代码以显示该页面上带有pagenation的所有博客帖子,直到这里所有工作文件。但是,如果我点击页面导航链接(上一页或下一页)然后wordpress将我重定向到404(找不到页面)'localhost / mysite.com / blog /'是好网址,但点击它后重定向我,'localhost / mysite .com / blog / page / 2'显示404错误,意味着wordpress将我重定向到我的原始页面上的其他地方,甚至将此页面设置为在wp管理面板中调用自定义模板。请帮我解决一下。
答案 0 :(得分:0)
转到“管理”面板信息中心
转到设置&gt;&gt;固定链接
更新永久链接。