Friday, May 17, 2024
HomeWordPress Developmentplugins - Wikipedia API and wordpress

plugins – Wikipedia API and wordpress


I’ve a PHP code, which prints article from Wikipedia. My drawback is to interchange VARIABLE with customized area from wordpress (PODS).

<?php
$url="http://en.wikipedia.org/w/api.php?motion=question&prop=extracts|data&titles=**VARIABLE**&format=json&explaintext&redirects&inprop=url&indexpageids";

       $json = file_get_contents($url);
       $knowledge = 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;


     ?>

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments