Untitled Snippet

Send Snippet To: Save this snippet to Code Collector Pro -- view all maeghan's snippets
language: PHP
license: BSD

Code for Snippet:

                
Display Blogroll Links
 
<ul>
<?php get_links_list(); ?>
</ul>
Display Admin Section
 
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<li><a href="http://www.wordpress.org/">WordPress</a></li>
<?php wp_meta(); ?>
<li><a href="http://validator.w3.org/check?uri=referer">XHTML</a></li>
</ul>
Display a Pages SubMenu in your Sidebar
 
This will display any subpages in your blog’s sidebar:
<?php$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');if ($children) { ?><ul> <?php echo $children; ?>
</ul>
<?php } ?>
Display WordPress Tags
 
<?php the_tags(); ?>
Display WordPress Tags Cloud
 
<?php wp_tag_cloud('smallest=8&largest=36&'); ?>
Template Name
 
This allows you to use the WordPress page template to customize how a page is displayed:
<?php /* Template Name: Portfolio */ ?>
Dynamic Title Tags
 
<title><?phpif (is_home()) { echo bloginfo('name');
} elseif (is_404()) {
echo '404 Not Found';
} elseif (is_category()) {
echo 'Category:'; wp_title('');
} elseif (is_search()) {
echo 'Search Results';
} elseif ( is_day() || is_month() || is_year() ) {
echo 'Archives:'; wp_title('');
} else {
echo wp_title('');
}
?></title>
Display PHP on a Single Page
 
Allows you to display plugins and such on a single page (replace home with the page you want it to only appear on):
<?php if ( is_home() ) { include ('file.php'); } ?>
Display an External RSS Feed
 
<?php include_once(ABSPATH.WPINC.'/rss.php');
wp_rss('http://wpforums.com/external.php?type=RSS2', 5); ?>
Display Most Recent Twitter Entry
 
<?php
// Your twitter username.
$username = "TwitterUsername";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace(&lt;,<, $tweet);
$tweet = str_replace(&gt;,>, $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>
I’m expecting this list to grow over time as I come across more useful WordPress code and update the post.
comments powered by Disqus

Info

Tags: wordpress

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 847
Date Added: 2009-04-27 23:59:13
Last Modified: 0000-00-00 00:00:00

Web Analytics