Php Wordpress帮助显示依赖于页面的帖子类别
我想根据页面显示特定的帖子类型,例如,我有一个博客帖子类型,我想显示当用户在/blog时,我有一个链接帖子类型,并且想在用户在/link时显示这些。这是可能的吗?目前我在index.php中有这段代码Php Wordpress帮助显示依赖于页面的帖子类别,php,wordpress,Php,Wordpress,我想根据页面显示特定的帖子类型,例如,我有一个博客帖子类型,我想显示当用户在/blog时,我有一个链接帖子类型,并且想在用户在/link时显示这些。这是可能的吗?目前我在index.php中有这段代码 <?php get_header(); ?> <div id="content"><!-- CONTENT START --> <h2><?php echo ucwords($post->post_title);?></h2&
<?php get_header(); ?>
<div id="content"><!-- CONTENT START -->
<h2><?php echo ucwords($post->post_title);?></h2>
<div id="subNavigation"><!-- SUBNAV START -->
<?php
if(get_the_title($post->post_parent) == "Members Content") {
$children .= '<li><a href="forums">Forums</a></li>';
$children .= '<li><a href="members">Members</a></li>';
$children .= '<li><a href="groups">Groups</a></li>';
} else {
$permalink = get_permalink($post->post_parent);
$children .= '<li><a href="'.$permalink.'">'. get_the_title($post->post_parent). '</a></li>';
}
if($post->post_parent)
$children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0");
else
$children .= wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
if ($children) { ?>
<ul>
<?php echo $children; ?>
</ul>
<?php } ?>
</div><!-- SUBNAV END -->
<div id="contentMainInterior"><!-- CONTENT MAIN START -->
<?php while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
</div><!-- CONTENT MAIN END -->
<div class="clear"></div>
</div><!-- CONTENT END -->
这会让你找到正确的方向:
这会让你找到正确的方向:
如果您正在谈论自定义帖子类型,最好的方法是为每个帖子类型索引页面创建模板。例如,您有一个名为“blog”的页面,并将其指定为“blog”模板,在该模板中,您可以编辑post查询以查找
“post\u type”=>“blog\u post”
或任何您的类型 如果您正在谈论自定义帖子类型,最好的方法是为每个帖子类型索引页面创建模板。例如,您有一个名为“blog”的页面,并将其指定为“blog”模板,在该模板中,您可以编辑post查询以查找“post\u type”=>“blog\u post”
或任何您的类型