Last active
September 27, 2022 09:39
-
-
Save webgurus/d3d916c5b95b152d08d8d4830aad048b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get 4 news item query | |
* @return array | |
*/ | |
public static function blogPostsLoop($post_ids = array(), $post_type = 'post', $showposts = '4', $exclude_posts = array()) { | |
$blogposts_query = array( | |
'post_type' => $post_type, | |
'post_status' => 'publish', | |
'posts_per_page' => $showposts, | |
'showposts' => $showposts, | |
'post__in' => $post_ids, | |
'post__not_in' => $exclude_posts, | |
); | |
$blogposts_query = new WP_Query( $blogposts_query ); | |
return $blogposts_query; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="featured-news-wrapper"> | |
<div class="row row-eq-height"> | |
@php $featured_post_ids = array() @endphp | |
@if($block->section_type == 'chosen-posts' && $block->featured_news ) | |
@php $query = App::blogPostsLoop($block->featured_news); @endphp | |
@else | |
@php $query = App::blogPostsLoop(); @endphp | |
@endif | |
@while($query->have_posts()) @php $query->the_post() @endphp | |
@php $featured_post_ids[] = get_the_ID(); @endphp | |
<div class="col-12 col-md-6 mb-3 mb-lg-5"> | |
<article class="card card-no-bg post"> | |
@if(has_post_thumbnail()) | |
<div class="section-image"> | |
<a href="{{ get_permalink() }}">{!! the_post_thumbnail('article_thumb') !!}</a> | |
</div> | |
<!-- /.section-image --> | |
@endif | |
<div class="card-body"> | |
<div class="card-title"> | |
<h3 class="mb-0"><a href="{{ get_permalink() }}">{{ the_title() }}</a></h3> | |
</div> | |
<!-- /.card-title --> | |
<div class="card-text small-text">{!! the_excerpt() !!}</div> | |
<a href="{{ get_permalink() }}" class="more">Read More</a> | |
</div> | |
{{-- /.card-body --}} | |
</article> | |
</div> | |
<!-- /.col-12 col-lg-4 pb-5 pb-lg-0 --> | |
@endwhile | |
@php wp_reset_postdata() @endphp | |
@php wp_reset_query() @endphp | |
</div> | |
<!-- /.row --> | |
</div> | |
{{-- /.featured-news-wrapper --}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment