December 30, 2024
1 min read
Essential Code Snippet For Web Developers
Post loop
<?php

$args = array(
    'posts_per_page' => 10,
    'post_type' => 'post',
);

$query = new WP_Query( $args );

?>

<?php if( $query->have_posts() ) : ?>
<div class='post_wrapper row'>
    <?php $count = 1;?>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>
    <?php 
        
        if($count===1){
            $col_class ='col-12';
         }else{
            $col_class ='col-6';
         }?>

    <div class="<?php echo $col_class?>">
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </div>

    <?php $count++;?>
    <?php endwhile; ?>
</div>
<?php endif; ?>

<?php wp_reset_query(); ?>

Leave a Reply

Your email address will not be published. Required fields are marked *

WordPress Post Approval Email Notification

Learn how to create a WordPress email notification system for post approvals. Customize email templates, support multiple post types, and improve user engagement with this developer-friendly guide.

Enabling Guest Checkout in WooCommerce: Bypassing Email Verification for Order Payment

Enable guest payment, bypass email verification. Enhance user experience, boost conversions. Easy, efficient, and customer-friendly solution

Allow Only Business Email Addresses in the Email Field of Elementor Forms

Find out how to restrict email fields in Elementor forms to business emails only. Improve form data quality by blocking free email domains like Gmail and Yahoo.

ACF

Easy ACF repeater Bootstrap accordion in WordPress

FAQ collapse design with ACF repeater Bootstrap accordion

Web Development Project in mind?

if you looking for a web developer for paid contribution to your project I am available for work.

Mukto
Mukto

Click the button below to chat with me.