WordPressã«ãã©ã°ã¤ã³ç¡ãã§ãå ¨ãã¼ã¸è¡¨ç¤ºã®ãã¼ã¸ãã¼ã·ã§ã³ããè¨ç½®ããæ¹æ³
ã³ãªã¹ããã®è¨äºå
ã³ã¼ããåããªãã£ãã®ã§ã°ã°ãã¤ã¤ã³ã¼ããæ¸ãã¾ããã
» WordPressã«ãã©ã°ã¤ã³ç¡ãã§ãã¼ã¸ãã¼ã·ã§ã³ãè¨ç½®ããæ¹æ³ | ã³ãªã¹
ãã¼ã¸ãã¼ã·ã§ã³ã®å®æäºæ³å³
functions.phpã«ä»¥ä¸ã®è¨è¿°
if ( ! function_exists( 'pietergoosen_pagination' ) ) :
function pietergoosen_pagination($pages = '', $range = 2) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
$string = _x( );
echo "<div class='pagination'>";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>" . __( '« First', 'pietergoosen' ) . "</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>" . __( '‹ Previous', 'pietergoosen' ) . "</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class="current">".$i."</span>":"<a href='".get_pagenum_link($i)."' class="inactive">".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='" . get_pagenum_link($paged + 1)."'>" . __( '次へ ›', 'pietergoosen' ) . "</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>" . __( '最後 »', 'pietergoosen' ) . "</a>";
echo "</div>n";
}
} // pietergoosen_pagination
endif;
ãã¼ã¸ãã¼ã·ã§ã³ã表示ããããé¨åã«ä»¥ä¸ãè¨è¿°ãã¾ã
<?php pietergoosen_pagination(); ?>
CSSã¯ãããªæã
.pagination span, .pagination a {
font-size: 15px;
padding: 10px 15px;
border: 1px solid #A0A0A0;
margin: 0 5px;
}
.pagination span.current {
border: 1px solid #A0A0A0;
background: #333;
color: #fff;
}
.pagination a:hover {
color: #333;
border: 1px solid #5E5E5E;
}
ãã£ãããã ãã§å®æã§ãã
ã³ããã§ãå©ç¨ãã ããã
â»PSï¼æ®æ®µã®æèããã¸ãã¹æ¦ç¥ã¯ãç©ã¿ä¸ãã¡ã«ãã¬ãããçºä¿¡ãã¦ãã¾ãã