function display_crypto_prices() {
$response = wp_remote_get(“https://api.coingecko.com/api/v3/simple/price?ids=bitcoin,ethereum,solana&vs_currencies=usd”);
if (is_wp_error($response)) {
return “Unable to fetch crypto data.”;
}
$body = wp_remote_retrieve_body($response);
$data = json_decode($body, true);
$output = “
“;
$output .= “
$output .= “
🟡 Bitcoin (BTC): $” . $data[‘bitcoin’][‘usd’] . “
“;
$output .= “
🟣 Ethereum (ETH): $” . $data[‘ethereum’][‘usd’] . “
“;
$output .= “
🔵 Solana (SOL): $” . $data[‘solana’][‘usd’] . “
“;
$output .= “
“;
return $output;
}
add_shortcode(‘crypto_prices’, ‘display_crypto_prices’);
