$logo_url,
'alt' => $logo_alt,
);
}
/**
* Render one AI tool card.
*/
function aitm_render_tool_card($post_id) {
$title = get_the_title($post_id);
$permalink = get_permalink($post_id);
$official_website = aitm_get_field('official_website', $post_id);
$short_description = aitm_get_field('short_description', $post_id);
$visit_count = aitm_get_field('visit_count', $post_id);
$button_text = aitm_get_field('button_text', $post_id);
$featured_tool = aitm_get_field('featured_tool', $post_id);
if (!$button_text) {
$button_text = 'Visit';
}
if (!$short_description) {
$short_description = get_the_excerpt($post_id);
}
$logo = aitm_get_tool_logo($post_id);
$categories = get_the_terms($post_id, 'ai_category');
ob_start();
?>
8,
), $atts);
$query = new WP_Query(array(
'post_type' => 'ai_tool',
'posts_per_page' => intval($atts['limit']),
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'featured_tool',
'value' => '1',
'compare' => '=',
),
),
));
ob_start();
echo '
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
echo aitm_render_tool_card(get_the_ID());
}
wp_reset_postdata();
} else {
echo '
No featured AI tools found.
';
}
echo '
';
return ob_get_clean();
}
add_shortcode('ai_featured_tools', 'aitm_featured_tools_shortcode');
/**
* Latest AI tools shortcode.
* Usage:

*/
function aitm_latest_tools_shortcode($atts) {
$atts = shortcode_atts(array(
'limit' => 12,
), $atts);
$query = new WP_Query(array(
'post_type' => 'ai_tool',
'posts_per_page' => intval($atts['limit']),
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'DESC',
));
ob_start();
echo '
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
echo aitm_render_tool_card(get_the_ID());
}
wp_reset_postdata();
} else {
echo '
No AI tools found.
';
}
echo '
';
return ob_get_clean();
}
add_shortcode('ai_latest_tools', 'aitm_latest_tools_shortcode');
/**
* Popular AI tools shortcode.
* Usage:

*/
function aitm_popular_tools_shortcode($atts) {
$atts = shortcode_atts(array(
'limit' => 8,
), $atts);
$query = new WP_Query(array(
'post_type' => 'ai_tool',
'posts_per_page' => intval($atts['limit']),
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'popular_tool',
'value' => '1',
'compare' => '=',
),
),
'meta_key' => 'visit_count',
'orderby' => 'meta_value_num',
'order' => 'DESC',
));
ob_start();
echo '
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
echo aitm_render_tool_card(get_the_ID());
}
wp_reset_postdata();
} else {
echo '
No popular AI tools found.
';
}
echo '
';
return ob_get_clean();
}
add_shortcode('ai_popular_tools', 'aitm_popular_tools_shortcode');
/**
* AI categories grid shortcode.
* Usage:
*/