繁体   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