plugins – Wikipedia API and wordpress
Question
I have a PHP code, which prints article from Wikipedia. My problem is to replace VARIABLE with custom field from wordpress (PODS).
<?php
$url="http://en.wikipedia.org/w/api.php?action=query&prop=extracts|info&titles=**VARIABLE**&format=json&explaintext&redirects&inprop=url&indexpageids";
$json = file_get_contents($url);
$data = json_decode($json);
$pageid = $data->query->pageids[0];
$title = $data->query->pages->$pageid->title;
$string=$data->query->pages->$pageid->extract;
$getarticle = str_replace(["==", "Biography", "References"], ["<br> <br>", "<b>Biography</b>", " " ], $string);
print $getarticle;
?>
0
2 months
2023-02-05T14:09:38-05:00
2023-02-05T14:09:38-05:00 0 Answers
0 views
0
Leave an answer