0

i wonder if there is a good way to create a shortcode that retrives a remote website FAV icon... i found this: ANSWER and tried to create a shortcode using it but failed (since i sux at shortcodes!)

A quote from the answer i linked up:

<?php 
$url = 'http://example.com/';
$doc = new DOMDocument();
$doc->strictErrorChecking = FALSE;
$doc->loadHTML(file_get_contents($url));
$xml = simplexml_import_dom($doc);
$arr = $xml->xpath('//link[@rel="shortcut icon"]');
echo $arr[0]['href'];
?>

Any help would be apreaciated ;)

1 Answer 1

1

OK... as it sometimes goes i cant rest until i find
a way and i found a way to get the fave icon to
proeprly display using google :)

its really simple:

// here i get my URL from my custom post type
$directoryNoHttpUrl = get_post_meta( $post->ID, 'directory_url', true );

//here i clean the url from HTTP or it wont work
$directoryNoHttpUrl = str_replace("http://", "", $directoryNoHttpUrl);

// here i get the favICON using google.. 
$imgurl = "http://s2.googleusercontent.com/s2/favicons?domain=" . $directoryNoHttpUrl;

.

So.. from here on its easy.
Sorry to trouble anyone entering to help
but thanks for your intention

Cheers, Sagive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.