2017-08-05 79 views
1

我想使我的自定義頁面模板,其中我顯示帖子與自定義樣式,我不知道如何顯示帖子在這個自定義頁面模板,在這裏我附上我的自定義頁面模板的簡單代碼。如何在WordPress中顯示自定義頁面模板中的帖子?

<?php 
/* 
Template Name: Custom Template 
*/ 
get_header(); 

    //custom code for post is here 
get_footer(); 
?> 
+1

它非常簡單您首先添加一個頁面並將其分配給您剛剛創建的模板並使用簡單的循環,或者您可以使用WP Query在其中添加您想要添加的所有樣式併爲其獲得樂趣。可以幫助你immensly https://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/ – sagar

回答

2

您可以隨時使用類似網頁模板,並充分利用代碼在我們自己的類和風格,你寫在這裏指的是:

<?php 
/* 
Template Name: Custom Template 
*/ 
get_header(); ?> 
<div id="primary" class="site-content"> 
    <div id="content" role="main"> 
<?php while (have_posts()) : the_post(); ?> 
    <header class="entry-header"> 
    <?php the_post_thumbnail(); ?> 
    <h1 class="entry-title"><?php the_title(); ?></h1> 
    </header> 

    <div class="entry-content"> 
    <?php the_content(); ?> 
    </div><!-- .entry-content --> 

    <?php comments_template('', true); ?> 
<?php endwhile; // end of the loop. ?> 
</div><!-- #content --> 

</div><!-- #primary --> 

<?php get_sidebar(); ?> 
<?php get_footer(); ?> 
+0

謝謝你的回答 – Avi

相關問題