Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. <div class="article_list">
  2. <ul>
  3. <?php
  4. //$cat = get_the_category(); // 表示中の記事のカテゴリ
  5. $parent_cat_id = 7; // 親カテゴリのIDを取得
  6. $categories = get_term_children( $parent_cat_id, 'category' );
  7. foreach ( $categories as $key => $value ) {
  8. $categories_num .= $value . ',';
  9. }
  10. $categories_num .= $parent_cat_id; //foreachのループ終了後親カテidを$categories_numに続けて代入
  11. //if ( query_posts( "cat=$categories_num&paged='.$paged" ) ): ;
  12. while ( have_posts() ): the_post();
  13. $parent_cat = get_category( $parent_cat_id ); // 親カテゴリの情報(オブジェクト)を取得
  14. $cat_name = $parent_cat->cat_name;
  15. ?>
  16. <?php
  17. //カテゴリスラッグをクラス名に出力(複数可)
  18. $str = '';
  19. foreach((get_the_category()) as $cat){
  20. $str .= $cat->category_nicename . ' ';
  21. }
  22. ?>
  23. <li class="<?php echo rtrim($str, " "); ?>">
  24. <a href="<?php the_permalink(); ?>">
  25. <div class="photo">
  26. <?php if(has_post_thumbnail()){
  27. the_post_thumbnail(array(248,184));
  28. }else{
  29. echo '<img src="/images/blog/no_image.png" width="74" alt="" />';
  30. } ?>
  31. </div>
  32. <div class="ttl">
  33. <?php the_title(); ?>
  34. </div>
  35. <?php
  36. $days = 14;
  37. $today = date_i18n( 'U' );
  38. $entry = get_the_time( 'U' );
  39. $elapsed = date( 'U', ( $today - $entry ) ) / 86400;
  40. if ( $days > $elapsed ) {
  41. echo '<img src="/images/common/icon_new.png" alt="New" class="icon_new"/>';
  42. }
  43. ?>
  44. </a>
  45. </li>
  46. <?php endwhile;?>
  47. </ul>
  48. <?php //else: ?>
  49.  
  50.  
  51. <?php //endif; ?>
  52. </div>
  53.  
  54. <?php
  55. function wp_pagenation() {
  56. global $wp_query;
  57. $big = 99999999;
  58. $page_format = paginate_links( array(
  59. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  60. 'format' => '?paged=%#%',
  61. 'current' => max( 1, get_query_var('paged') ),
  62. 'total' => $wp_query->max_num_pages,
  63. 'prev_next' => True,
  64. 'prev_text' => __('<img src="/images/column/pn_prev.png" height="20" alt=""/>'),
  65. 'next_text' => __('<img src="/images/column/pn_next.png" height="20" alt=""/>'),
  66. 'type' => 'array'
  67. ) );
  68. if( is_array($page_format) ) {
  69. //echo '<div><ul>';
  70. foreach ( $page_format as $page ) {
  71. echo "<li>$page</li>";
  72. }
  73. // echo '</ul></div>';
  74. }
  75. wp_reset_query();
  76. }
  77. ?>
  78. <ul class="pagenation"><?php wp_pagenation(); ?></ul>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement