Industry Insights & Technical Resources
Profloortech Knowledge Hub
Technical guides, sourcing tips, and project insights for raised floor professionals worldwide.
'post',
'post_status' => 'publish',
'posts_per_page' => 12,
'paged' => $search_paged,
);
if (strlen($q) >= 2) {
$args['s'] = $q;
}
$blog_query = new WP_Query($args);
$total_pages = $blog_query->max_num_pages;
ob_start();
if ($blog_query->have_posts()) :
echo '
while ($blog_query->have_posts()) : $blog_query->the_post();
$post_id = get_the_ID();
$post_title = get_the_title();
$post_url = get_permalink();
$post_date = get_the_date('M j, Y');
$post_excerpt = get_the_excerpt();
$post_cat = '';
$cats = get_the_category();
if (!empty($cats)) {
$post_cat = esc_html($cats[0]->name);
}
if (has_post_thumbnail($post_id)) {
$thumb_id = get_post_thumbnail_id($post_id);
$thumb_img = wp_get_attachment_image($thumb_id, 'medium_large', false, array(
'class' => 'w-full h-full object-cover transition-transform duration-500 group-hover:scale-105',
'loading' => 'lazy',
'decoding'=> 'async',
'sizes' => '(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw',
'alt' => esc_attr($post_title),
));
} else {
$thumb_img = '';
}
$display_title = esc_html($post_title);
$display_excerpt = esc_html(wp_trim_words($post_excerpt, 18, '...'));
if (strlen($q) >= 2) {
$safe_q = preg_quote($q, '/');
$highlight = '$0';
$display_title = preg_replace('/(' . $safe_q . ')/iu', $highlight, $display_title);
$display_excerpt = preg_replace('/(' . $safe_q . ')/iu', $highlight, $display_excerpt);
}
$safe_url = esc_url($post_url);
$safe_date = esc_html($post_date);
$safe_cat = $post_cat;
echo <<
{$thumb_img}
HTML;
endwhile;
echo '
';
else :
$no_result_msg = strlen($q) >= 2
? 'No articles found for "' . esc_html($q) . '". Try a different keyword.'
: 'No articles published yet. Check back soon.';
echo <<
{$no_result_msg}
HTML;
endif;
wp_reset_postdata();
// Pagination
if ($total_pages > 1) {
$q_encoded = urlencode($q);
echo '
';
}
$html = ob_get_clean();
hx_response($html);
}
?>
type="search"
name="q"
value="= esc_attr($search_query) ?>"
placeholder="Search articles by keyword..."
autocomplete="off"
hx-get="/wp-json/zeroy/v1/htmx/execute/current?block_id== $block_id ?>"
hx-target="#blog-results-= $block_id ?>"
hx-swap="innerHTML"
hx-trigger="input changed delay:500ms, search"
hx-indicator="#search-indicator-= $block_id ?>"
class="w-full bg-neutral-800/60 border border-primary-700/40 rounded-xl pl-12 pr-12 py-3.5 text-white text-sm placeholder-neutral-500 focus:outline-none focus:ring-2 focus:ring-secondary/50 focus:border-secondary/50 transition-all duration-200"
aria-label="Search blog articles"
/>
'post',
'post_status' => 'publish',
'posts_per_page' => 12,
'paged' => $paged,
);
if (strlen($search_query) >= 2) {
$init_args['s'] = $search_query;
}
$init_query = new WP_Query($init_args);
$total_pages = $init_query->max_num_pages;
if ($init_query->have_posts()) :
?>
$post_id = get_the_ID();
$post_title = get_the_title();
$post_url = get_permalink();
$post_date = get_the_date('M j, Y');
$post_excerpt = get_the_excerpt();
$post_cat = '';
$cats = get_the_category();
if (!empty($cats)) {
$post_cat = esc_html($cats[0]->name);
}
if (has_post_thumbnail($post_id)) {
$thumb_id = get_post_thumbnail_id($post_id);
$thumb_img = wp_get_attachment_image($thumb_id, 'medium_large', false, array(
'class' => 'w-full h-full object-cover transition-transform duration-500 group-hover:scale-105',
'loading' => 'lazy',
'decoding' => 'async',
'sizes' => '(max-width: 640px) 100vw, (max-width: 1024px) 50vw, 33vw',
'alt' => esc_attr($post_title),
));
} else {
$thumb_img = '';
}
?>
= $thumb_img ?>
1) : ?>
No articles published yet. Check back soon.