Use WordPress functions externally


I did some quick research and was surprised to find how easy it was to add wordpress function to pages that were external to the blog site folder.

Find the path on which your blogs root it, on the path there is a file wp-config.php. This file once reference on your external page opens the WordPress world to that page. Mine is in a folder called blog. I wanted to include a function in my index page on the root of hypixdesign.com. I added the following code.

1
require_once('blog/wp-config.php')

This allowed me to add the follow code to my index page:

1
2
3
4
$tagArray = wp_tag_cloud('format=array');
foreach($tagArray as $tag) {
	echo "<div id=\"tag\">" . $tag . "</div>\n";
}

This allowed me to display all the tags in a tag cloud format (different size text based on number the number of times the tag was used). You can check out the results on the root of this domain (http://www.hypixdesign.com).

Simple.

Share on Facebook Share on Facebook


Write a Comment

Take a moment to comment and tell us what you think. Some basic HTML is allowed for formatting.

Reader Comments

Be the first to leave a comment!