<?php
// WP Shortcode
function vq_recent_blogs_shortcode() {

    $the_query = new WP_Query( array(
        'posts_per_page' => 3,
    ));

    $i = 1;
    $str = "<div class='container'> <div class='row'>";
    if ( $the_query->have_posts() ) :

        while ( $the_query->have_posts() ) : $the_query->the_post();

            $str .= '<div class="col-sm-4">
                <div class="recentReviewBox white">
                    <img class="recentReviewImage" src="'. get_the_post_thumbnail_url() .'" alt="">
                    <div class="col-sm-12">
                        <div class="recentReviewHeading">
                            <h4>0'. $i++ .'</h4>
                        </div>
                        <div class="topBlog">
                            <h4>'. get_the_title() .'</h4>
                        </div>
                        <div class="post">
                            <p>'. get_the_excerpt() .'</p>
                        </div>
                    </div>
                    <div class="hrBorder mt-0"></div>
                    <div class="d-flex j-content-center">
                        <a href="'. get_the_permalink() .'"><button type="button" class="btn blogReadMore mt-3">Read More</button></a>
                    </div>
                </div>
            </div>';

        endwhile;
    else :
        __('No News');
    endif;

    return $str .= '</div></div>';
}

add_shortcode('recent-blogs', 'vq_recent_blogs_shortcode');



function vq_recent_reviews_shortcode() {

    $the_query = new WP_Query( array(
        'posts_per_page' => 3,
        'post_type' => 'hosting_reviews'
    ));

    $i = 1;
    $str = "<div class='container'> <div class='row'>";
    if ( $the_query->have_posts() ) :

        while ( $the_query->have_posts() ) : $the_query->the_post();

            $str .= '<div class="col-sm-4">
                <div class="recentReviewBox white">
                    <img class="recentReviewImage" src="'. get_the_post_thumbnail_url() .'" alt="">
                    <div class="col-sm-12">
                        <div class="recentReviewHeading">
                            <h4>0'. $i++ .'</h4>
                        </div>
                        <div class="topBlog">
                            <h4>'. get_the_title() .'</h4>
                        </div>
                        <div class="post">
                            <p>'. get_the_excerpt() .'</p>
                        </div>
                    </div>
                    <div class="hrBorder mt-0"></div>
                    <div class="d-flex j-content-center">
                        <a href="'. get_the_permalink() .'"><button type="button" class="btn blogReadMore mt-3">Read More</button></a>
                    </div>
                </div>
            </div>';

        endwhile;
    else :
        __('No News');
    endif;

    return $str .= '</div></div>';
}

add_shortcode('recent-reviews', 'vq_recent_reviews_shortcode');
