<?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(); ?>
i have created custom post type named Bolg using CPT(custom post type) plugin. and and i copied page.php content to my new file named blog-page.php and then copy my code to display all blog post with pagenation on that page till here everything works file. but if i click to pagenation nav links (prev or next) then wordpress redirects me to 404(page not found) on ‘localhost/mysite.com/blog/’ is ok url but after clicking it redirect me to , ‘localhost/mysite.com/blog/page/2’ which shows 404 error, means wordpress redirect me to somewhere else not on my orginal page, even is set this page to call custom template in wp admin panel. please help me how to resolve it.
Go to Admin panel dashboard
Go to settings >> permalinks
update your permalinks.