Skip to content

Instantly share code, notes, and snippets.

@hissy hissy/gist:6103177
Last active Jun 28, 2019

Embed
What would you like to do?
[WordPress] どうしても固定ページテンプレートでページ送り付きのアーカイブが作りたいのよと言う場合
<?php
/**
* Template Name: Archive Page */
?>
<?php
$paged = (int) get_query_var('paged');
$args = array(
'posts_per_page' => 3,
'paged' => $paged,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'post',
'post_status' => 'publish'
);
$the_query = new WP_Query($args);
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
get_template_part( 'content', get_post_format() );
endwhile;
else:
get_template_part( 'content', 'none' );
endif;
if ($the_query->max_num_pages > 1) {
echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%/',
'current' => max(1, $paged),
'total' => $the_query->max_num_pages
));
}
wp_reset_postdata();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.