将wordpress管理页面内容与自定义模板相结合?

时间:2014-06-02 17:49:14

标签: php wordpress

有没有办法将wordpress页面的主要textarea中的内容与其自定义模板中的内容合并?

在这种情况下,我有一个自定义模板,显示来自单个类别的所有帖子,但我还希望有一个部分显示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页面管理区域内容显示,用户通常会写入textarea以显示在页面上,这可能吗?

1 个答案:

答案 0 :(得分:0)

这就是我提出的:

<?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; ?>

这可以接受吗?它起作用了,但我不确定它有多优雅!

相关问题