WordPress.org

Ready to get started?Download WordPress

Forums

want to grab wikipedia articles (3 posts)

  1. antishape
    Member
    Posted 2 years ago #

    Hi, I have this code and want to know how to extend it that way so it gets tags for a post and display each articles based on a single tag. The code is:

    function get_wiki($search) {
    	if(!$search) return false;
    	$url = "http://de.wikipedia.org/w/api.php?format=xml&action=parse&page=".$search;
    	$xml = simplexml_load_file($url);
    	$text = $xml->parse->text;
    	if(!$text) return false;
    
    	$reg_exp = '/<p>(.*?)<\/p>/s';
    	preg_match_all($reg_exp, $text, $match);
    	$summary = $match[0][0];
    
    	if($summary == "<p><b>Artikel verschwunden?</b></p>") return false;
    
    	$summary = ereg_replace('href="/wiki/', 'href="/ueber/', $summary);
    
    	return $summary;
    }

    Now I'd like to know how and where to add get tags and make the code do seperate every tag so it gets tags one by one and not all of them at once like "tage1tag2tag3" it should be:
    tag1

    tag2

    tag3

    would be great if you can tell me how and where to add that code.

    Kind regards

  2. antishape
    Member
    Posted 2 years ago #

    I am now using the wikibox plugin and via shortcode I could put every summary in the post I like but I still need it automatically because there already over 1000 posts in the blog and it won't be great to extend them all manually.

    So I need an alternative version. Great. This code allows me to get a summary for the wikipedia article of Pink Floyd:
    <?php if ( function_exists( 'wikibox_summary' ) ) wikibox_summary( 'Pink Floyd' ); ?>

    If I put the_tags in the same place as Pink Floyd (instead of Pink Floyd) I don't get anything. Not even an error message. Do have any idea how to handle this even if there are more tags than one?

  3. antishape
    Member
    Posted 2 years ago #

    Ok now I don't just add the_tags instead of Pink Floyd I did this:

    $ptags = the_tags();

    and put it in place instead of Pink Floyd. But doesn't change anything. OK it will be displayed but the same way as Tags usually will be displayed not as a wikibox.

    So now it looks like:
    <?php if ( function_exists( 'wikibox_summary' ) ) wikibox_summary( '$ptags' ); ?>

    But doesn't help me.

    Anyone? Please!?

Topic Closed

This topic has been closed to new replies.

About this Topic