汇编大量WordPress代码
显示最新文章
1 2 3 4 5 6 7 8 |
<ol class="dp-c"> <li class="alt"><span><span><?php query_posts(</span><span class="string">’showposts=5′</span><span>); ?> </span></span></li> <li><span><ul> </span></li> <li class="alt"><span><?php <span class="keyword">while</span><span> (have_posts()) : the_post(); ?> </span></span></li> <li><span><li><a href=<span class="string">"<?php the_permalink() ?>"</span><span>><?php the_title(); ?></a></li> </span></span></li> <li class="alt"><span><?php <span class="keyword">endwhile</span><span>;?> </span></span></li> <li><span></ul> </span></li> </ol> |
显示最新评论
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<ol class="dp-c"> <li class="alt"><span><span><?php </span></span></li> <li><span><span class="keyword">global</span><span> </span><span class="vars">$wpdb</span><span>; </span></span></li> <li class="alt"><span><span class="vars">$sql</span><span> = "SELECT DISTINCT ID, post_title, post_password, comment_ID, </span></span></li> <li><span>comment_post_ID, comment_author, comment_date_gmt, comment_approved, </span></li> <li class="alt"><span>comment_type,comment_author_url, </span></li> <li><span>SUBSTRING(comment_content,1,30) AS com_excerpt </span></li> <li class="alt"><span>FROM <span class="vars">$wpdb</span><span>->comments </span></span></li> <li><span>LEFT OUTER JOIN <span class="vars">$wpdb</span><span>->posts ON (</span><span class="vars">$wpdb</span><span>->comments.comment_post_ID = </span></span></li> <li class="alt"><span><span class="vars">$wpdb</span><span>->posts.ID) </span></span></li> <li><span>WHERE comment_approved = <span class="string">‘1′</span><span> AND comment_type = </span><span class="string">”</span><span> AND </span></span></li> <li class="alt"><span>post_password = <span class="string">”</span><span> </span></span></li> <li><span>ORDER BY comment_date_gmt DESC </span></li> <li class="alt"><span>LIMIT 10"; </span></li> <li><span><span class="vars">$comments</span><span> = </span><span class="vars">$wpdb</span><span>->get_results(</span><span class="vars">$sql</span><span>); </span></span></li> <li class="alt"><span><span class="vars">$output</span><span> = </span><span class="vars">$pre_HTML</span><span>; </span></span></li> <li><span><span class="vars">$output</span><span> .= </span><span class="string">"n<ul>"</span><span>; </span></span></li> <li class="alt"><span><span class="keyword">foreach</span><span> (</span><span class="vars">$comments</span><span> </span><span class="keyword">as</span><span> </span><span class="vars">$comment</span><span>) { </span></span></li> <li><span><span class="vars">$output</span><span> .= </span><span class="string">"n<li>"</span><span>.</span><span class="func">strip_tags</span><span>(</span><span class="vars">$comment</span><span>->comment_author) </span></span></li> <li class="alt"><span>.<span class="string">":"</span><span> . </span><span class="string">"<a href=""</span><span> . get_permalink(</span><span class="vars">$comment</span><span>->ID) . </span></span></li> <li><span><span class="string">"#comment-"</span><span> . </span><span class="vars">$comment</span><span>->comment_ID . </span><span class="string">"" title="on "</span><span> . </span></span></li> <li class="alt"><span><span class="vars">$comment</span><span>->post_title . </span><span class="string">"">"</span><span> . </span><span class="func">strip_tags</span><span>(</span><span class="vars">$comment</span><span>->com_excerpt) </span></span></li> <li><span>.<span class="string">"</a></li>"</span><span>; </span></span></li> <li class="alt"><span>} </span></li> <li><span><span class="vars">$output</span><span> .= </span><span class="string">"n</ul>"</span><span>; </span></span></li> <li class="alt"><span><span class="vars">$output</span><span> .= </span><span class="vars">$post_HTML</span><span>; </span></span></li> <li><span><span class="func">echo</span><span> </span><span class="vars">$output</span><span>;?> </span></span></li> </ol> |
显示热评文章
1 2 3 4 5 6 7 8 9 10 |
<ol class="dp-c"> <li class="alt"><span><span><?php </span><span class="vars">$result</span><span> = </span><span class="vars">$wpdb</span><span>->get_results(</span><span class="string">"SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 10"</span><span>); </span></span></li> <li><span><span class="keyword">foreach</span><span> (</span><span class="vars">$result</span><span> </span><span class="keyword">as</span><span> </span><span class="vars">$topten</span><span>) { </span></span></li> <li class="alt"><span><span class="vars">$postid</span><span> = </span><span class="vars">$topten</span><span>->ID; </span></span></li> <li><span><span class="vars">$title</span><span> = </span><span class="vars">$topten</span><span>->post_title; </span></span></li> <li class="alt"><span><span class="vars">$commentcount</span><span> = </span><span class="vars">$topten</span><span>->comment_count; </span></span></li> <li><span><span class="keyword">if</span><span> (</span><span class="vars">$commentcount</span><span> != 0) { ?> </span></span></li> <li class="alt"><span><li><a href=<span class="string">"<?php echo get_permalink($postid); ?>"</span><span> </span></span><span><span>title=</span><span class="string">"<?php echo $title ?>"</span><span>><?php </span><span class="func">echo</span><span> </span><span class="vars">$title</span><span> ?></a></li> </span></span></li> <li><span><?php } } ?> </span></li> </ol> |
显示文章分类 [...
有公众号之类的吗,之前这个网站打不开了
[…] 关于使用Change…
[…] 关于使用Functi…
谢谢提醒,已删 :)
还有你上边文章的图片里有一个账户名没有打…