function serviceBox_loop() { $arg = array( 'post_type' => 'service', 'posts_per_page' => -1, ); $servicePost = new WP_Query($arg); ?> <div class="singl-servce-sec"> <div class="row"> <?php if ($servicePost->have_posts()): ?> <?php while ($servicePost->have_posts()): $servicePost->the_post(); $url = wp_get_attachment_url(get_post_thumbnail_id($servicePost->ID)) ?> <div class="col-md-6"> <div class="serv-thumb"> <img src="<?php echo $url ?>" alt="" class="img-thumb"> <div class="services-content"> <h2><?php the_title(); ?></h2> <div class="par1" ><?php the_content(); ?></div> <a href="<?php echo the_permalink(); ?>"><?php echo get_field('btntxt2') ?><img src="<?php echo get_template_directory_uri(); ?>/img/detailarro.png" alt=""></a> </div> </div> </div> <?php endwhile; ?> <?php endif; ?> </div> </div> <?php wp_reset_postdata(); } add_shortcode('serviceWithbox', 'serviceBox_loop');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter