Wordpress Programing Question For Experts

mikaop

Power Member
Joined
Jan 5, 2021
Messages
577
Reaction score
319
Here is The Code :

<section class="segment">
<div class="container">

<header>
<h2 class="heading"><?php _e('Our Services', THEME_NAME) ?></h2>
<span class="heading-divider">
<span></span>
</span>
</header>

<div class="row align-items-stretch">

<?php while ($services->have_posts()): $services->the_post(); ?>

<div class="col-lg-3 col-md-6 col-sm-6 mb-4">

<div class="box-service"
style="background-image: url('<?php print get_the_post_thumbnail_url(null, 'medium') ?>')">

<h4 class="title">
<a href="<?php the_permalink() ?>"><?php print get_the_title() ?></a>
</h4>
<div class="description">
<?php the_excerpt() ?>
</div>
<a href="<?php the_permalink() ?>" class="btn btn-primary btn-block">
<?php _e('Discover More', THEME_NAME) ?>
</a>
</div>
</div>

<?php endwhile;
wp_reset_query(); ?>

</div>
</div>
</section>

What This Code Does :

This code displays the last 4 Services Added on the homepage

What I Want The code to do

I Want the code to display the 4 Services i want , using something like Index which i think is possible cause this is a loop , however it's a dynamic loop i don't mind making it working using index [0,1,2] or something like this
 
Back
Top