10 Most Used Wordpress Tags in Design Wordpress Theme
Wednesday, November 26, 2008 15:30
This time I am lists 10 most used wordpress code snippets or wordpress tags in designing wordpress theme.
These code snippets are used in standard wordpress theme. This time, I am lists, 10 most used wp tags in sidebar.
Please save it for further reference. Here is:
1. Shows The Pages
<?php wp_list_pages(‘title_li=<h2>Pages</h2>’); ?>
The code above will lists all your website pages you have.
2. Shows The Categories
<li id=”categories”><?php _e(‘Categories:’); ?>
<ul>
<?php wp_list_cats(); ?>
</ul>
</li>
The code above will lists all categories your website have, except an empty category. The category with no post yet.
How to shows the categories in a dropdown menu? use this wordpress tag:
<li><h2>Categories</h2>
<form action=”<?php get_option(‘home’): ?>/” method=”get” class=”dropdown”>
<?php wp_dropdown_categories(’show_count=1&hierarchical=1′); ?>
<input type=”submit” name=”submit” value=”view” class=”button” />
</form>
</li>
3. Displays Recent Posts
<?php wp_get_archives(‘type=postbypost&limit=15′); ?>
The code above will lists the 15 newest our posts. You can change the number to list some number posts you like.
4. To Show Monthly Archives
<li id=”archives”><?php _e(‘Archives:’); ?>
<ul>
<?php wp_get_archives(‘type=monthly’); ?>
</ul>
</li>
The code will displays the monthly archive in standar list format.
Use the code below to display the monthly archives in dropdown menu format.
<li><h2>Archives</h2>
<select name=”archive-dropdown” onChange=’document.location.href=this.options[this.selectedIndex].value;’ id=”archives”>
<option value=”"><?php echo attribute_escape(__(‘Select Month’)); ?></option>
<?php wp_get_archives(‘type=monthly&format=option’); ?>
</select>
</li>
5. Displays The Link Lists
<?php get_links_list(); ?>
This code will lists all links we have in all categories and also with the sub categories.
6. To Display Registered User
<h2>Link list of authors:</h2>
<ul>
<?php
$order = ‘user_nicename’;
$user_ids = $wpdb->get_col(“SELECT ID FROM $wpdb->users ORDER BY $order”); // query users
foreach($user_ids as $user_id) : // start authors’ profile “loop”
$user = get_userdata($user_id);
?>
<li><?php echo ‘<a href=”‘ . $user->user_url . ‘”>’ . $user->display_name . ‘</a>’; ?><br /></li>
<?php
endforeach; // end of authors’ profile ‘loop’
?>
</ul>
The code above will list all registered users in our sidebar.
7. Shows The Active Authors
<li><h2>Most Active Authors</h2>
<ul>
<?php wp_list_authors(’show_fullname=1&optioncount=1′); ?>
</ul>
</li>
The code above will shows us, the list of active authors. The user who have post only. Users with no post, not showed.
8. How to Display Feeds Links
<li><a href=”feed:<?php bloginfo(‘rss2_url’); ?>”
title=”<?php _e(‘Syndicate this site using RSS’); ?>”>
<?php _e(‘<abbr title=”Really Simple Syndication”>RSS</abbr>’); ?>
</a></li>
Use the code to display feed link in our sidebar.
9. How to show login and register links
To show the login, register and site admin link (if logged in), use this code.
<ul id=”loginout”>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
<?php wp_register(); ?>
</ul>
10. How to Display The Standard Search Form
Use this code:
<li>
<form method=”get” id=”searchform” action=”<?php get_option(‘home’): ?>/”>
<input type=”text” value=”<?php the_search_query(); ?>” name=”s” id=”s” />
<input type=”submit” id=”searchsubmit” value=”search” class=”button” />
</form>
</li>
You can read this post in Indonesian at Open Community Tutorial
