簡體   English   中英

結合WordPress管理頁面內容與自定義模板?

[英]Combining wordpress admin page content with custom template?

有沒有一種方法可以將Wordpress頁面主要文本區域中的內容與其自定義模板中的內容結合起來?

在這種情況下,我有一個自定義模板,該模板顯示一個類別中的所有帖子,但是我也想有一個部分來顯示在WordPress管理頁面區域中寫的內容。

這就是我設置自定義模板以顯示相關帖子的方式:

<?php query_posts('category_name=baby-coupons'); ?>

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>                  

    <h2><a href="<?php the_permalink() ;?>"><?php the_title() ;?></a> <span class="post-date">- <?php the_time('F j, Y'); ?></span></h2>

    <div class="row">

        <div class="one-third">

            <?php 
            if ( has_post_thumbnail() ) { 
              the_post_thumbnail();
            } 
            ?>

        </div>

        <div class="two-third last">

            <?php the_excerpt() ;?>

        </div> 

    </div><!--/row-->    

    <hr>    

    <?php endwhile; ?>

在此之上,我想顯示wordpress頁面管理區域的內容,用戶通常會寫什么到文本區域以顯示在頁面上,這可能嗎?

這是我想出的:

<?php get_posts(); ?>

<?php while ( have_posts() ) : the_post(); ?>  
    <?php the_content() ;?>
<?php endwhile; ?>

<?php query_posts('category_name=baby-coupons'); ?>          

    <?php /* Start the Loop */ ?>
    <?php while ( have_posts() ) : the_post(); ?>                  

    <h2><a href="<?php the_permalink() ;?>"><?php the_title() ;?></a> <span class="post-date">- <?php the_time('F j, Y'); ?></span></h2>

    <div class="row">

        <div class="one-third">

            <?php 
            if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
              the_post_thumbnail();
            } 
            ?>

        </div>

        <div class="two-third last">

            <?php the_excerpt() ;?>

        </div> 

    </div><!--/row-->    

    <hr>    

    <?php endwhile; ?>

這可以接受嗎? 它正在工作,但我不確定它有多優雅!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM