PHP WordPress:自定义子导航

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP WordPress:自定义子导航相关的知识,希望对你有一定的参考价值。

<?php
	global $post; $thispage = $post->ID; // grabs the current post id from global and then assigns it to $thispage
	$subpages = get_pages("child_of=".$thispage."&sort_column=menu_order"); // gets a list of pages that are sub pages of $thispage and assigns it to $pagekids
?>

<?php if ($subpages) { // if there are any values stored in $pagekids, meaning there are sub-pages of the current page ?>

	<ul class="links">
		<?php wp_list_pages("depth=1&title_li=&sort_column=menu_order&child_of=".$thispage); // display ONLY the sub pages of the current page ?>
	</ul>

<?php } else { // $pagekids is empty ?>

	<ul class="links">
		<?php wp_list_pages('depth=1&title_li=&child_of='.$post->post_parent.'&sort_column=menu_order'); // display the sub-pages of the current parent page ?>
	</ul>

<?php } ?>

以上是关于PHP WordPress:自定义子导航的主要内容,如果未能解决你的问题,请参考以下文章

延迟加载 UICollectionViewCell 的自定义子视图

为啥自定义子查询类型不能分配给 GraphQLObjectType?

防止 UITableView 在自定义子视图处理触摸时滚动

XamarinAndroid组件教程设置自定义子元素动画

plotly可视化绘制多子图(subplots)并自定义子图

Qt从顶层调用自定义子目标