Php 我能';t正确加载立柱的子立柱
我不熟悉PHP和WordPress 我正在使用插件创建我的自定义类型(更多信息请访问) 这是我的代码:Php 我能';t正确加载立柱的子立柱,php,wordpress,custom-post-type,Php,Wordpress,Custom Post Type,我不熟悉PHP和WordPress 我正在使用插件创建我的自定义类型(更多信息请访问) 这是我的代码: <?php $args = array('post_type' => 'project-list'); $myposts = get_posts( $args ); foreach ( $myposts as $post ) : ?> <span><?php echo $post -&
<?php
$args = array('post_type' => 'project-list');
$myposts = get_posts( $args );
foreach ( $myposts as $post ) :
?>
<span><?php echo $post -> post_title; ?></span>
<ul class="project-list">
<?php
$argsChild = array('orderby' => 'post-order', 'order' => 'ASC');
$mypostsChild = types_child_posts('project', $argsChild);
foreach ( $mypostsChild as $postChild ) :
?>
<li>
<p class="project-cost"><?php echo $postChild -> post_title; ?></p>
<span class="project-name"><?php echo $postChild -> fields['project-name']; ?></span>
<hr />
<p class="project-type"><?php echo $postChild -> fields['project-type']; ?></p>
<hr />
<span class="project-location"><?php echo $postChild -> fields['project-location']; ?></span>
</li>
<?php endforeach; ?>
</ul>
<?php endforeach; ?>
问:如何根据自定义字段类型对子帖子进行排序,在我的例子中是“post order”
谢谢大家 帖子没有任何父项或子项。职位按类别创建。您应该在“类别”下创建一些类别和子类别。i、 e 类别:项目组名称-1
-子类别:pro 1
-子类别:专业2 类别:项目组名称-2
-子类别:pro 1
-子类别:专业2 此外,您还创建了自定义帖子类型。根据您的规范,有许多方法可以检索自定义帖子类型的术语。不过,请尝试以下代码以了解其中的含义:
<?php
//list terms in a given taxonomy
$taxonomy = 'project-list';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
}
?>
</ul>
了解更多关于和的信息。阅读此链接,您将获得更多与您的需求相关的代码。这些会帮助你的
仅供参考:页面有父页面或子页面您给了我一个想法。我将以不同的方式来做这件事。无论如何,谢谢你。
<?php
//list terms in a given taxonomy
$taxonomy = 'project-list';
$tax_terms = get_terms($taxonomy);
?>
<ul>
<?php
foreach ($tax_terms as $tax_term) {
echo '<li>' . '<a href="' . esc_attr(get_term_link($tax_term, $taxonomy)) . '" title="' . sprintf( __( "View all posts in %s" ), $tax_term->name ) . '" ' . '>' . $tax_term->name.'</a></li>';
}
?>
</ul>