Wordpress主题设计常用代码

显示最近文章:

1. < ?php wp_get_archives('type=postbypost&limit=5'); ?>

或者:

1. < ?php $recentposts = get_posts('numberposts=12&category=4');<BR>foreach ($recentposts as $post) : setup_postdata($post); ?> </P>
2. <LI><A href="<?php the_permalink() ?>">< ?php the_title(); ?></A> 
3. <P>< ?php endforeach; ?>

  • 显示分类:

    1. <BR>
    2. <H2>Categories</H2>
    3. <UL>< ?php wp_list_cats('sort_column=name'); ?> </UL>
    4. <P>

    显示存档:

    1. <BR>
    2. <H2>Archives</H2>
    3. <UL>< ?php wp_get_archives('type=monthly'); ?> </UL>
    4. <P>

    显示标签云:

    1. < ?php wp_tag_cloud('smallest=8&largest=36&'); ?>

    显示友情链接:

    1. <UL>< ?php wp_list_bookmarks('title_li=&categorize=0'); ?> </UL>
    2. <P>

    显示标签:

    1. < ?php the_tags(); ?>

    显示页面导航菜单:

    1. <BR>
    2. <H2>Pages</H2>
    3. <UL>< ?php wp_list_pages('title_li='); ?> </UL>
    4. <P>

    显示最新评论:

    1. < ?php<BR>global $wpdb;<BR>$sql = "SELECT DISTINCT ID, post_title, post_password, comment_ID,<BR>comment_post_ID, comment_author, comment_date_gmt, comment_approved,<BR>comment_type,comment_author_url,<BR>SUBSTRING(comment_content,1,30) AS com_excerpt<BR>FROM $wpdb->comments<BR>LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID =<BR>$wpdb->posts.ID)<BR>WHERE comment_approved = '1' AND comment_type = '' AND<BR>post_password = ''<BR>ORDER BY comment_date_gmt DESC<BR>LIMIT 10";<BR>$comments = $wpdb->get_results($sql);<BR>$output = $pre_HTML;<BR>$output .= "\n 
    2. <UL>";<BR>foreach ($comments as $comment) {<BR>$output .= "\n 
    3. <LI>".strip_tags($comment->comment_author)<BR>.":" . "<A href='\""' get_permalink($comment- .>ID) .<BR>"#comment-" . $comment->comment_ID . "\" title=\"on " .<BR>$comment->post_title . "\">" . strip_tags($comment->com_excerpt)<BR>."</A> 
    4. <P>";<BR>}<BR>$output .= "\n</P></LI></UL>
    5. <P>";<BR>$output .= $post_HTML;<BR>echo $output;?>

    显示管理面板:

    1. <UL>< ?php wp_register(); ?> 
    2. <P></P>
    3. <LI>< ?php wp_loginout(); ?> 
    4. <LI><A href="http://www.wordpress.org/">WordPress</A> 
    5. <P>< ?php wp_meta(); ?> </P>
    6. <LI><A href="http://validator.w3.org/check?uri=referer">XHTML</A> </LI></UL>
    7. <P>

    显示热门评论:

    1. < ?php $result = $wpdb->get_results("SELECT<BR>comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count<BR>DESC LIMIT 0 , 10");<BR>foreach ($result as $topten) {<BR>$postid = $topten->ID;<BR>$title = $topten->post_title;<BR>$commentcount = $topten->comment_count;<BR>if ($commentcount != 0) { ?> </P>
    2. <LI><A href="<?php echo get_permalink($postid); ?>" title="< ?php echo $title ?>">< ?php echo $title<BR>?></A> 
    3. <P>< ?php } } ?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值