tailieunhanh - Tìm Hiểu về Wordpress - part 13

Tham khảo tài liệu 'tìm hiểu về wordpress - part 13', công nghệ thông tin, đồ họa - thiết kế - flash phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | a href php echo get_permalink comment- comment_post_ID . comment- . comment- comment_ID php echo dp_get_author comment a php echo strip_tags substr apply_filters get_ comment_text comment- comment_content 0 comment_len li php ob_end_flush else echo li No Comments li function dp_get_author comment author if empty comment- comment_author author Anonymous else author comment- comment_author return author To use this function simply call it from anywhere in your theme php dp_recent_comments 6 Displaying Recent Posts Lets do this again from easiest to hardest. Widget - The easiest possible way to do this is through a widgetized sidebar. 107 Resetting The query string is set when any page in WordPress is loaded. You can override it by doing you own query_posts but then that original query string is destroyed. You can restore it with this wp_reset_query Just like recent comments there is a built-in Recent Posts widget which will do the trick. Just drag it into your sidebar zone and save it. Function - We don t have to write a custom function this time we can just use the wp_get_archives function which we already looked at a little. A simple function like this will display linked titles to recent posts php wp_get_archives type postbypost limit 5 Custom Loop - Finally we could go totally home-brew and just write a custom loop to display recent posts. This offers by far the most control as we can do anything inside this loop including accessing the full content or custom fields. php query_posts posts_per_page 10 what_to_show posts orderby date if have_posts while have_posts the_post output custom stuff here Post title content custom fields. endwhile else message if nothing found endif wp_reset_query . Listing Popular Posts Popularity is more loosely defined than something like recent. How do you define popularity Page views Number of comments Back links If you want to accommodate all the above try the WordPress Popular Posts plugin which is available at http .