Our Projects
Davis and Sons Construction delivers excavation, grading, utility, and site development projects throughout Northeast Tennessee and Southwest Virginia.
function vdctn_projects_grid_shortcode() {
$projects = new WP_Query(array(
‘post_type’ => ‘project’,
‘posts_per_page’ => 4,
‘post_status’ => ‘publish’,
‘orderby’ => ‘date’,
‘order’ => ‘DESC’
));
if (!$projects->have_posts()) {
return ‘
No projects found.
‘;
}
ob_start();
echo ‘
while ($projects->have_posts()) {
$projects->the_post();
$project_id = get_the_ID();
$title = get_the_title();
$link = get_permalink();
$service_type = get_field(‘service_type’, $project_id);
$location = get_field(‘project_location’, $project_id);
echo ‘
if (has_post_thumbnail()) {
echo ‘‘;
echo get_the_post_thumbnail($project_id, ‘large’);
echo ‘‘;
}
if ($service_type) {
echo ‘
‘;
}
echo ‘
‘ . esc_html($title) . ‘
‘;
if ($location) {
echo ‘
‘;
}
echo ‘
‘;
}
echo ‘
‘;
wp_reset_postdata();
return ob_get_clean();
}
add_shortcode(‘projects_grid’, ‘vdctn_projects_grid_shortcode’);
