Advertisement
cyberdev

Untitled

Jul 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template part for displaying posts from the same category as current post.
  4. *
  5. * @license For the full license information, please view the Licensing folder
  6. * that was distributed with this source code.
  7. *
  8. * @package Bimber_Theme 4.10
  9. */
  10.  
  11. // Prevent direct script access.
  12. if ( ! defined( 'ABSPATH' ) ) {
  13. die( 'No direct script access allowed' );
  14. }
  15.  
  16. $bimber_post_first_category = bimber_get_post_first_category( get_the_ID() );
  17.  
  18. if ( ! empty( $bimber_post_first_category ) ) {
  19. $bimber_args = array(
  20. 'cat' => $bimber_post_first_category->term_id,
  21. 'post__not_in' => array( get_the_ID() ), // Exclude current post.
  22. 'posts_per_page' => bimber_get_more_from_posts_limit(),
  23. 'ignore_sticky_posts' => true,
  24. );
  25. } else {
  26. $bimber_args = array();
  27. }
  28.  
  29. $bimber_query = new WP_Query( $bimber_args );
  30. ?>
  31.  
  32. <?php if ( $bimber_query->have_posts() ) : ?>
  33.  
  34. <?php
  35. $bimber_more_from_elements = bimber_conver_string_to_bool_array(
  36. bimber_get_theme_option( 'post', 'more_from_hide_elements' ),
  37. array(
  38. 'featured_media' => true,
  39. 'avatar' => true,
  40. 'categories' => true,
  41. 'summary' => true,
  42. 'author' => true,
  43. 'date' => true,
  44. 'shares' => true,
  45. 'views' => true,
  46. 'comments_link' => true,
  47. )
  48. );
  49.  
  50. $bimber_settings = apply_filters( 'bimber_entry_more_from_settings', array(
  51. 'elements' => $bimber_more_from_elements,
  52. ) );
  53.  
  54. bimber_set_template_part_data( $bimber_settings );
  55. ?>
  56. <aside class="g1-more-from">
  57. <h2 class="g1-beta g1-beta-2nd"><?php printf( wp_kses_post( __( 'More From: <a href="%s">%s</a>', 'bimber' ) ), esc_url( get_category_link( $bimber_post_first_category->term_id ) ), esc_html( $bimber_post_first_category->name ) ) ?></h2>
  58.  
  59. <div class="g1-collection">
  60. <div class="g1-collection-viewport">
  61. <ul class="g1-collection-items">
  62. <?php while ( $bimber_query->have_posts() ) : $bimber_query->the_post(); ?>
  63.  
  64. <li class="g1-collection-item">
  65. <?php get_template_part( 'template-parts/content-list-standard-custom', get_post_format() ); ?>
  66. </li>
  67.  
  68. <?php endwhile; ?>
  69. </ul>
  70. </div>
  71. </div>
  72.  
  73. <?php bimber_reset_template_part_data(); ?>
  74. <?php wp_reset_postdata(); ?>
  75. </aside>
  76. <?php endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement