Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="article_list">
- <ul>
- <?php
- //$cat = get_the_category(); // 表示中の記事のカテゴリ
- $parent_cat_id = 7; // 親カテゴリのIDを取得
- $categories = get_term_children( $parent_cat_id, 'category' );
- foreach ( $categories as $key => $value ) {
- $categories_num .= $value . ',';
- }
- $categories_num .= $parent_cat_id; //foreachのループ終了後親カテidを$categories_numに続けて代入
- //if ( query_posts( "cat=$categories_num&paged='.$paged" ) ): ;
- while ( have_posts() ): the_post();
- $parent_cat = get_category( $parent_cat_id ); // 親カテゴリの情報(オブジェクト)を取得
- $cat_name = $parent_cat->cat_name;
- ?>
- <?php
- //カテゴリスラッグをクラス名に出力(複数可)
- $str = '';
- foreach((get_the_category()) as $cat){
- $str .= $cat->category_nicename . ' ';
- }
- ?>
- <li class="<?php echo rtrim($str, " "); ?>">
- <a href="<?php the_permalink(); ?>">
- <div class="photo">
- <?php if(has_post_thumbnail()){
- the_post_thumbnail(array(248,184));
- }else{
- echo '<img src="/images/blog/no_image.png" width="74" alt="" />';
- } ?>
- </div>
- <div class="ttl">
- <?php the_title(); ?>
- </div>
- <?php
- $days = 14;
- $today = date_i18n( 'U' );
- $entry = get_the_time( 'U' );
- $elapsed = date( 'U', ( $today - $entry ) ) / 86400;
- if ( $days > $elapsed ) {
- echo '<img src="/images/common/icon_new.png" alt="New" class="icon_new"/>';
- }
- ?>
- </a>
- </li>
- <?php endwhile;?>
- </ul>
- <?php //else: ?>
- <?php //endif; ?>
- </div>
- <?php
- function wp_pagenation() {
- global $wp_query;
- $big = 99999999;
- $page_format = paginate_links( array(
- 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
- 'format' => '?paged=%#%',
- 'current' => max( 1, get_query_var('paged') ),
- 'total' => $wp_query->max_num_pages,
- 'prev_next' => True,
- 'prev_text' => __('<img src="/images/column/pn_prev.png" height="20" alt=""/>'),
- 'next_text' => __('<img src="/images/column/pn_next.png" height="20" alt=""/>'),
- 'type' => 'array'
- ) );
- if( is_array($page_format) ) {
- //echo '<div><ul>';
- foreach ( $page_format as $page ) {
- echo "<li>$page</li>";
- }
- // echo '</ul></div>';
- }
- wp_reset_query();
- }
- ?>
- <ul class="pagenation"><?php wp_pagenation(); ?></ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement