我有两个单独的页面,显示了链接到wordpress中完整帖子的不同类别列表。这两个目前在我的主题single.php打开,但类别需要在每个页面上不同的风格。在不同的页面中打开wordpress帖子
我已经创建的模板页,但不知道如何打开手机的single.php
以外的其他页面上的帖子,以简化:我怎样打开帖子上的single.php
的另一个版本代码我有打开完整的职位是:
<?php // PAGE LINK/TITLE
if (is_page()) {
$cat=get_cat_ID($post->post_title); //use page title to get a category ID
$posts = get_posts ("category_name=case-study&posts_per_page=10");
if ($posts) {
foreach ($posts as $post):
setup_postdata($post);
?>
<div class="serve-inner-split">
<div id="case-split">
<div id="case-left" class=" serve-left">
<div id="case-study-content">
<h1 class="case-study-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
<p><?php //PULLS IN EXCERPT
$my_excerpt = get_the_excerpt();
if ('' != $my_excerpt) {
// Some string manipulation performed
}
echo $my_excerpt; // Outputs the processed value to the page
?>
</p>
<a href="#" class="header-quote">READ CASE STUDY</a>
</div>
</div>
<div id="case-right" class="serve-grey">
<?php
if (has_post_thumbnail()) { // PULLS IN IMAGE check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
?>
</div>
</div>
</div>
<?php endforeach;
}
}
?>
或者他可以以不同的方式添加类别字段和样式index.php;) –
自定义帖子类型是我最喜欢的“开箱即用”解决方案,对于WP管理员面板不太熟悉的用户也很方便使用:) – markoffden