Created
March 5, 2018 14:55
-
-
Save asadaly111/a51e00e1b7e94a09471b420335984c8f to your computer and use it in GitHub Desktop.
ESPN News feed Shortcode in Wordpress - ESPN News feed in Wordpress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//add this is function.php | |
function cs_shortcode_by_asad(){ | |
$data = file_get_contents('https://newsapi.org/v2/top-headlines?sources=espn&apiKey=d0261b1877794a6085b66c81714f273f'); | |
$data = json_decode($data); | |
$content = ''; | |
$content .= '<ul class="newsfeedsgoese">'; | |
foreach ($data->articles as $key): | |
$content .= '<li><a target="_blank" href="'.$key->url.'"><img src="'.$key->urlToImage.'" alt=""><h3>'.$key->title.'</h3></a></li>'; | |
endforeach; | |
$content .= '</ul>'; | |
return $content; | |
} | |
add_shortcode( 'news-feeds-by-dev-team', 'cs_shortcode_by_asad'); | |
//add this shorcode whereever you want to add[news-feeds-by-dev-team] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment