Tutorials
02 Sep 2026
Live Cricket Score WordPress Plugin — Add Scores to Your Website (2026)
Add live cricket scores to your WordPress website using CricLive API. Step-by-step guide to building a WordPress plugin that shows live scores, scorecards, and match schedules.
CricLive Team
CricketLiveApi Team
Add Live Cricket Scores to Your WordPress Website
Want to show live cricket scores on your WordPress website? This guide shows you how to build a simple WordPress plugin that fetches live scores from CricLive API and displays them using a shortcode.
Step 1 — Create the Plugin File
Create wp-content/plugins/criclive-scores/criclive-scores.php:
<?php
/**
* Plugin Name: CricLive Scores
* Description: Live cricket scores powered by CricLive API
* Version: 1.0.0
*/
define('CRICLIVE_API_KEY', 'your_api_key_here');
define('CRICLIVE_BASE_URL', 'https://cricketliveapi.com/api/v1');
function criclive_get_live_scores() {
$response = wp_remote_get(CRICLIVE_BASE_URL . '/cricket/live', [
'headers' => ['Authorization' => 'Bearer ' . CRICLIVE_API_KEY],
'timeout' => 10,
]);
if (is_wp_error($response)) return [];
$body = json_decode(wp_remote_retrieve_body($response), true);
return $body['data'] ?? [];
}
function criclive_scores_shortcode($atts) {
$matches = criclive_get_live_scores();
if (empty($matches)) return 'No live matches right now.
';
$html = '';
foreach ($matches as $match) {
$html .= sprintf(
'%s vs %s
%s
%s',
esc_html($match['team1']),
esc_html($match['team2']),
esc_html($match['score'] ?? ''),
esc_html($match['status'] ?? '')
);
}
$html .= '';
return $html;
}
add_shortcode('criclive_scores', 'criclive_scores_shortcode');Step 2 — Add Styles
.criclive-scores { font-family: sans-serif; }
.criclive-match {
border: 1px solid #e2e8f0;
border-radius: 8px;
padding: 12px 16px;
margin-bottom: 10px;
background: #f8fafc;
}Step 3 — Use the Shortcode
Add [criclive_scores] to any page or post to display live cricket scores.
Step 4 — Auto-Refresh with JavaScript
// Add to your theme or plugin
setInterval(() => {
fetch('?criclive_ajax=1')
.then(r => r.text())
.then(html => {
document.querySelector('.criclive-scores').innerHTML = html;
});
}, 30000); // Refresh every 30 secondsGet your free API key at cricketliveapi.com/register and add live cricket scores to your WordPress site today.