Advertisement
Osama_Mersal

Untitled

Jan 7th, 2025
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2. $related_posts = buddyboss_theme_get_option( 'blog_related_switch' );
  3. ?>
  4.  
  5. <?php if ( is_single() && ! is_related_posts() && !empty( $related_posts ) ) : ?>
  6.     <div class="post-related-jobs">
  7.         <h4><?php _e( 'Related Jobs', 'buddyboss-theme' ); ?></h4>
  8.         <?php
  9.         global $post, $is_related_posts;
  10.  
  11.         $posts_array = buddyboss_theme()->related_posts_helper()->get_related_posts();
  12.         $posts_array = wp_list_pluck( $posts_array, 'ID' );
  13.  
  14.         $args = array(
  15.             'post_type' => 'job_listing',
  16.             'post__in' => $posts_array,
  17.             'post__not_in' => array( $post->ID ),
  18.             'orderby' => 'post__in',
  19.             'order' => 'ASC',
  20.             'ignore_sticky_posts' => true,
  21.         );
  22.  
  23.         $post_query = new WP_Query( $args );
  24.         $is_related_posts = true;
  25.  
  26.         // The Loop
  27.         if ( $post_query->have_posts() ) { ?>
  28.             <ul class="job_listings job_listings_grid">
  29.             <?php
  30.                 while ( $post_query->have_posts() ) {
  31.                     $post_query->the_post();
  32.                     get_template_part( 'template-parts/content', 'job_related' );
  33.                 }
  34.                 /* Restore original Post Data */
  35.                 wp_reset_postdata(); ?>
  36.             </ul><?php
  37.         }
  38.  
  39.         $is_related_posts = false;
  40.         ?>
  41.     </div>
  42. <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement