wordpress functions

WordPress functions

1.bloginfo()

bloginfo(‘name’) display the name of blog

bloginfo(‘description’)

bloginfo(‘url’) the website url

bloginfo(‘template_url’) display the template of wordpress

<?php href="<?php bloginfo('url'); ?> title ="<?php bloginfo('description'); ?>" <?php bloginfo('name') ?> ?>

2.wp_title()
wp_title(‘separator’.echo,seplocation)

separator :>>

echo: true will display the tiel, false will return the title as php parameter

for example:

<title>
<?php wp_title('|','true','right');?>
<?php bloginfo('name'); ?>-<?php bloginfo('description'); ?>
</title>

3.

wp_get_archives()

wp_get_archives('type=monthly&format=html&show_post_count=1&limit=10')

type=monthly ,could be replaced by yearly, daily, weekly

show_post_count=1 display number ,1 means bool

limit=10 means the display max is 10

4.

wp_list_categories()

wp_list_categories('orderby=name&order=ASC&show_count=1&use_desc_for_title=1&feed=RSS&exlude=2,5& number =10')

show_count=1 means display number of posts

use_desc_for_title=1 means use the description to create a hyperlink

feed=RSS creates a “RSS” hyperlink

exlude=2,5 only display id =2 and 5 categories

number=10 only display the first 10 categories

5

get_the_category()

cat_ID: current category ID

cat_name: current category name

category_description: current cateogry descripiton

category_count: current category posts number

6
the_category()

7

category_description()
echo category_description(get_category()->cat_ID)

8 is_home()

to check whether the current page is the homepage for the blog or not. the return is bool. true or false

<?php if(is_home()){//the content to display in homepage}else{//the content to display not in the homepage} ?>

9.is_archive()

check if the page is archive page

10.is_page()

check if the webpage is the page of blog

11.is_paged()

check if the page has if exist, return false

12.

is_page_template()

is_page_template('guestbook.php') ///to chekc guestbook.php used template or not 

13.is_single()

is_single('808';)

14.is_category()
return bool

15.is_tag()

16.is_date()

17.

is_day()  is_mounth() is _year()

18.is_author()

19.is_admin() under the panel of admin

20.get_bloginfo()

21.query_posts()

query_posts("order=ASC&showposts=10&offset=1&orderby=date&posts_per_page=5")

showposts=10 display 10 posts

offset=1 display the latest post

posts_per_page=5, display 5 posts per page

for example

<li><h2>Latest posts</h2>
    <?php query_posts('showposts=5&offset=1'); ?>
    <ul>
        <?php while(have_posts()):the_post(): ?>
        <li><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" </li>
        <?php endwhile ?>
    </ul>
</li>

22.get_posts()

<?php
$lastposts=get_posts('numberposts=5');
foreach($lastposts as $post) :setup_postdata($post);
 ?>
<h2><a href="<?php the_permlink(); ?>" id="post-<?php the_ID(); ?>" ><?php the_title();?></h2>
<?php the_content(); ?>
<?php endforeach; ?>

23.

wp_list_cats()

24.get_calendar()

25.

wp_list_bookmarks()
wp_list_bookmarsk('title_li=&categorize=0&orderby=rand&include=41,40,37,54')

title_li=&categorize=0 means not display the the bookmarks title but display the category

orderby=rand rand means randomly, could be replaced by id,url,anme

include=41,40,37,54 means display the categoryid =41,40,37,54 

26.

wp_list_pages('title_li=&sort_column=menu_order&include=12,25,37,54&depth=1&')

title_li= means the name of these all pages, if null, it won't display name

sort_column=menu_order means the order of pages, could be replaced by post_title, post_date, ID

depth=1 means display parent page, 0 means display all pages, -1 displayg all pages 

27.

wp_tag_cloud()

wp_tag_cloud('smallest=8&largest=22&number=30&orderby=count')

smallest=8 means tag font size is 8 (least tags)
largest=22 means tag font size is 22 (most tags)

28.wp_register()

29.wp_loginout()

30.

wp_logout_url()
wp_login_url()
<a href="<?php echo wp-logout_url(); ?>" >
<a href="<?php echo wp-login_url(); ?>" >

31.wp_meta()

32.wp_recent_posts()

33.get_recent_comments()

34.

wp_get_post_tags()

if(is_single()){
    $keywords="";
    $tags=wp_get_post_tags($post->ID);
    foreach($tags as $tag){
        $keywords=$keywords.$tag->name.",":
    }
    echo $keywords;
}

35.

single_cat_title() single_tag_title()

<?php $str=single_cat_title() echo $str ?>
<?php $str=single_tag_title() echo $str ?>

36.get the post here

<?php if(have_posts()) ?>
<?php while(have_posts()):the_postt() ?>

37.the_title()

<?php the_title('before','after',display); ?>