/nx/index.php

https://bitbucket.org/Trulsh/personal-bootstrap-projects · PHP · 79 lines · 45 code · 34 blank · 0 comment · 7 complexity · 903ae69eed863f5d69e4213de42dccd3 MD5 · raw file

  1. <?php get_header(); ?>
  2. <div class="container my-5">
  3. <?php if(is_search()) { ?>
  4. <h1><?php esc_html_e( 'Results for:', 'nx'); ?> <?php echo $s; ?></h1>
  5. <?php } else if(is_category() || is_tag() ) { ?>
  6. <h1><?php echo single_cat_title(); ?></h1>
  7. <?php } else { ?>
  8. <h1><?php bloginfo('description');?></h1>
  9. <?php } ?>
  10. <hr>
  11. </div>
  12. <main class="container">
  13. <div class="row">
  14. <div class="col-sm-8">
  15. <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  16. <article <?php post_class(); ?>>
  17. <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
  18. <p> <?php the_time('j M Y'); ?> - <?php the_category(', ');?></p>
  19. <a href="<?php the_permalink(); ?>">
  20. <?php the_post_thumbnail('nx_single', array( 'class' => 'img-fluid mb-4', 'alt' => get_the_title() ))?>
  21. </a>
  22. <?php the_excerpt(); ?>
  23. </article>
  24. <hr class="my-5">
  25. <?php endwhile; ?>
  26. <div class="pagination">
  27. <?php
  28. global $wp_query;
  29. $big = 999999999; // need an unlikely integer
  30. echo paginate_links( array(
  31. 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
  32. 'format' => '?paged=%#%',
  33. 'current' => max( 1, get_query_var('paged') ),
  34. 'total' => $wp_query->max_num_pages
  35. ) );
  36. ?>
  37. </div>
  38. <?php else: ?>
  39. <p><?php esc_html_e('Sorry, no post matched your criteria.', 'nx'); ?></p>
  40. <?php endif; ?>
  41. </div>
  42. <?php get_sidebar(); ?>
  43. </div>
  44. </main>
  45. <?php get_footer(); ?>