Tweaking Your WordPress Without Plugins
Posted by Asuka_Aki | Posted in Wordpress | Posted on 15-06-2008 |
If you don’t see what you need check this out for more ways to tweak your wordpress template.
Plugins can be an easy way time saving of doing things but too many plugins is not recommended due to incompatibilities and the constant upgrades of WordPress. With WordPress 2.5 there a number of things that you can do without plugins. Such as:
Display recent posts:
<?php query_posts(’showposts=5′); ?>
<ul>
<?php while (have_posts()) : the_post(); ?>
<li><a href=”<?php the_permalink() ?>”><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>
Display recent comments:
<?php
global $wpdb;
$sql = “SELECT DISTINCT ID, post_title, post_password, comment_ID,
comment_post_ID, comment_author, comment_date_gmt, comment_approved,
comment_type,comment_author_url,
SUBSTRING(comment_content,1,30) AS com_excerpt
FROM $wpdb->comments
LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =
$wpdb->posts.ID)
WHERE comment_approved = ‘1′ AND comment_type = ” AND
post_password = ”
ORDER BY comment_date_gmt DESC
LIMIT 10″;
$comments = $wpdb->get_results($sql);
$output = $pre_HTML;
$output .= “\n<ul>”;
foreach ($comments as $comment) {
$output .= “\n<li>”.strip_tags($comment->comment_author)
.”:” . “<a href=\”" . get_permalink($comment->ID) .
“#comment-” . $comment->comment_ID . “\” title=\”on ” .
$comment->post_title . “\”>” . strip_tags($comment->com_excerpt)
.”</a></li>”;
}
$output .= “\n</ul>”;
$output .= $post_HTML;
echo $output;?>
Display Top Comments:
<?php $result =
$wpdb->get_results(”SELECT comment_count,ID,post_title FROM
$wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10″);
foreach ($result as $topten) {
$postid = $topten->ID;
$title = $topten->post_title;
$commentcount = $topten->comment_count;
if ($commentcount != 0) { ?>
<li><a href=”<?php echo get_permalink($postid); ?>”
title=”<?php echo $title ?>”><?php echo $title
?></a></li>
<?php } } ?>
Display Tags
<?php the_tags(); ?>
Tag Cloud
<?php wp_tag_cloud(”); ?>
Default Usage
$defaults = array(’smallest’ => 8, ‘largest’ => 22,
‘unit’ => ‘pt’, ‘number’ => 45, ‘format’ => ‘flat’,
‘orderby’ => ‘name’, ‘order’ => ‘ASC’,'exclude’ => , ‘include’ => );
By default, the usage shows:
- smallest - The smallest tag (lowest count) is shown at size 8
- largest - The largest tag (highest count) is shown at size 22
- unit - Describes ‘pt’ (point) as the font-size unit for the smallest and largest values
- number - Displays at most 45 tags
- format - Displays the tags in flat (separated by whitespace) style
- orderby - Order the tags by name
- order - Sort the tags in ASCENDING fashion
- exclude - Exclude no tags
- include - Include all tags
Visit the WordPress Codex if you need to further customize the code.
Displaying Gravatars
This to can be customised in a different number a ways.
Visit the WordPress codex for more info.
<?php echo get_avatar( $id_or_email, $size = ‘96′, $default = ‘<path_to_url>’ ); ?>
Display Categories
<h2>Categories</h2><ul>
<?php wp_list_cats(’sort_column=name’); ?>
</ul>
Display Archives
<h2>Archives</h2>
<ul>
<?php wp_get_archives(’type=monthly’); ?>
</ul>
Pages Menu
<h2>Pages</h2>
<ul>
<?php wp_list_pages(’title_li=’); ?>
</ul>
Display Subpages Menu:
<?php$children = wp_list_pages(’title_li=&child_of=’.$post->ID.
‘&echo=0′);if ($children) { ?><ul> <?php echo $children; ?>
</ul>
<?php } ?>
Display Blogroll
<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>
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>
Include or Exclude Categories
To sort categories alphabetically and include only the categories with IDs of 16, 3, 9 and 5, you could write the following code:
<ul>
<?php
wp_list_categories(’orderby=name&include=3,5,9,16′); ?>
</ul>
The following example displays category links sorted by name, shows the number of posts for each category, and excludes the category with the ID of 10 from the list.
<ul>
<?php
wp_list_categories(’orderby=name&show_count=1&exclude=10′); ?>
</ul>
If you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!




it is easy way
thanks alot
[...] UPDATE: More ways to tweak your themplate! [...]
[...] August 18, 2008 by blogpusher Plugins can be an easy way time saving of doing things but too many plugins is not recommended due to incompatibilities and the constant upgrades of WordPress. Too many plugins slow down your server. With WordPress 2.5 and higher there a number of things that you can do without plugins. Read this article to find some cool codes. [...]
[...] 18, 2008 by blogpusher I love WordPress 2.5 because it is free and because it gives me all the creative liberty I need. I [...]