custom_blog.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * This file adds the blog page template to the Captivating theme.
  4. *
  5. * @package Captivating
  6. * @link http://restored316designs.com/themes
  7. * @author Lauren Gaige // Restored 316 LLC
  8. * @copyright Copyright (c) 2015, Restored 316 LLC, Released 08/09/2017
  9. * @license GPL-2.0+
  10. */
  11. /*
  12. Template Name: Custom Blog
  13. */
  14. /** Replace the standard loop with our custom loop */
  15. remove_action( 'genesis_loop', 'genesis_do_loop' );
  16. add_action( 'genesis_loop', 'captivating_do_custom_loop' );
  17. function captivating_do_custom_loop() {
  18. global $paged; // current paginated page
  19. global $query_args; // grab the current wp_query() args
  20. $args = array(
  21. 'paged' => $paged, // respect pagination
  22. );
  23. genesis_custom_loop( wp_parse_args($query_args, $args) );
  24. }
  25. //* Add archive body class to the head
  26. add_filter( 'body_class', 'captivating_add_archive_body_class' );
  27. function captivating_add_archive_body_class( $classes ) {
  28. $classes[] = 'captivating-custom-blog';
  29. return $classes;
  30. }
  31. //* Adds Flexible Featured Content Above Content on Blog Page Template
  32. add_action( 'genesis_after_header', 'captivating_above_blog_content' );
  33. function captivating_above_blog_content() {
  34. genesis_widget_area( 'above-blog-content', array(
  35. 'before' => '<div id="above-blog-content" class="above-blog-content"><div class="wrap">',
  36. 'after' => '</div></div>',
  37. ) );
  38. }
  39. //* Remove Featured image (if set in Theme Settings)
  40. add_filter( 'genesis_pre_get_option_content_archive_thumbnail', 'captivating_no_post_image' );
  41. function captivating_no_post_image() {
  42. return '0';
  43. }
  44. //* Show Excerpts regardless of Theme Settings
  45. add_filter( 'genesis_pre_get_option_content_archive', 'captivating_show_excerpts' );
  46. function captivating_show_excerpts() {
  47. return 'excerpts';
  48. }
  49. //* Modify the length of post excerpts
  50. add_filter( 'excerpt_length', 'captivating_excerpt_length' );
  51. function captivating_excerpt_length( $length ) {
  52. return 60; // pull first 50 words
  53. }
  54. //* Modify the Excerpt read more link
  55. add_filter('excerpt_more', 'captivating_new_excerpt_more');
  56. function captivating_new_excerpt_more($more) {
  57. return '... <br><a class="more-link" href="' . get_permalink() . '">Read More</a>';
  58. }
  59. //* Make sure content limit (if set in Theme Settings) doesn't apply
  60. add_filter( 'genesis_pre_get_option_content_archive_limit', 'captivating_no_content_limit' );
  61. function captivating_no_content_limit() {
  62. return '0';
  63. }
  64. //* Display centered wide featured image for First Post and left aligned thumbnail for the next five
  65. add_action( 'genesis_entry_header', 'captivating_show_featured_image', 8 );
  66. function captivating_show_featured_image() {
  67. if ( ! has_post_thumbnail() ) {
  68. return;
  69. }
  70. global $wp_query;
  71. if( ( $wp_query->current_post <= 0 ) ) {
  72. $image_args = array(
  73. 'size' => 'horizontal-entry-image',
  74. 'attr' => array(
  75. 'class' => 'aligncenter',
  76. ),
  77. );
  78. } else {
  79. $image_args = array(
  80. 'size' => 'vertical-entry-image',
  81. 'attr' => array(
  82. 'class' => 'alignleft',
  83. ),
  84. );
  85. }
  86. $image = genesis_get_image( $image_args );
  87. echo '<div class="home-featured-image"><a href="' . get_permalink() . '">' . $image .'</a></div>';
  88. }
  89. //* Remove entry meta
  90. remove_action( 'genesis_entry_header', 'genesis_post_info', 9 );
  91. //* Run the default Genesis loop
  92. genesis();