大家的Wordpress的網站文章一多,就需要一個顯示所有文章的頁面,那麼今天就來教大家如何免外掛給Wordpress添加一個「所有文章」頁面
教程
1、在你的主題文件夾在內新建一個文件名為「all-post.php」
2、在新建的文件中添加下列內容(當然你可以更改一下樣式來符合你網站的主題)
| 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | <?php /* Template Name: Archives */ ?> <?php get_header(); ?> 	<script type="text/javascript"> 		/* <![CDATA[ */ 			jQuery(document).ready(function() {                 function setsplicon(c, d) {                     if (c.html()=='+' || d=='+') {                         c.html('-');                         c.removeClass('car-plus');                         c.addClass('car-minus');                     } else if( !d || d=='-'){                         c.html('+');                         c.removeClass('car-minus');                         c.addClass('car-plus');                     }                 } 				jQuery('.car-collapse').find('.car-yearmonth').click(function() { 					jQuery(this).next('ul').slideToggle('fast');                     setsplicon(jQuery(this).find('.car-toggle-icon')); 				}); 				jQuery('.car-collapse').find('.car-toggler').click(function() { 					if ( '展開所有月份' == jQuery(this).text() ) { 						jQuery(this).parent('.car-container').find('.car-monthlisting').show(); 						jQuery(this).text('折疊所有月份');                        setsplicon(jQuery('.car-collapse').find('.car-toggle-icon'), '+'); 					} 					else { 						jQuery(this).parent('.car-container').find('.car-monthlisting').hide(); 						jQuery(this).text('展開所有月份');                         setsplicon(jQuery('.car-collapse').find('.car-toggle-icon'), '-'); 					} 					return false; 				}); 			}); 		/* ]]> */ 	</script> <div id="roll"> 	<div title="回到頂部" id="roll_top"></div> 	<div title="轉到底部" id="fall"></div> </div> <div id="content"> 	<div class="main"> 		<div id="mapsite"> 			當前位置: <a title="返回首頁" href="<?php echo get_settings('Home'); ?>/">首頁</a> > 所有文章 		</div> 		<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 		<div class="left left_page"> 			<h2>文章歸檔</h2> 			<div class="article article_page"> 				<p class="articles_all"> 					「<strong><?php bloginfo('name'); ?></strong>」目前共有文章: <?php echo $hacklog_archives->PostCount();?>篇	 				</p> 				<?php echo $hacklog_archives->PostList();?> 			</div> 		</div> 	<?php endwhile; else: ?> 	<?php endif; ?> </div> <?php get_sidebar(); ?> <?php get_footer(); ?> | 
3、新建一個頁面,將標題設為「所有文章」並把內容留空,最後把頁面右側的「頁面屬性」-「模板」的選項改為「Archives」
4、看一下你的頁面,是不是出來你的所有文章啦? 
預覽
總結
1、前面PHP文件的內容一定要記得按照自己主題的樣式來更改(最簡單的方法是參考你主題別的文件)
2、有問題可以回覆 
