3

我遇到了以下问题。

我制作了 2 种自定义帖子类型,当然,每种都包含帖子。

但是现在我遇到了需要在存档页面顶部添加自定义字段的情况。

由于我没有可以在管理员端访问的页面,因此我无法填写这些自定义字段。

我应该切换到一个页面,还是有其他方法?

我希望这足够清楚。

4

1 回答 1

1

这样做的可能方法是创建一个页面并将内容放在那里,然后在存档“post-type”.php 顶部使用以下代码来显示它。

$myposts = get_posts( array('post_type'=>'page','numberposts' => 1,'include' => 45) );
foreach( $myposts as $post ) :  setup_postdata($post); ?>

    <article id="post-<?php the_ID(); ?>" <?php post_class('grid_5'); ?>>
                <header class="entry-header">
                    <h1 class="entry-title"><?php the_title(); ?></h1>
                </header><!-- .entry-header -->
                <div class="entry-content">
                    <?php the_content(); ?>
                </div><!-- .entry-content -->
            </article><!-- #post-<?php the_ID(); ?> -->
         <?php endforeach; // end of the loop. ?>

您需要做的就是将 'include' => 45 替换为您自己的页面 ID。

于 2013-08-01T12:13:15.357 回答