默认情况下,wp\\u list\\u页面会显示一个无序的帖子标题列表。为了节省侧边栏菜单中的空间,我尝试创建一个页面段塞列表,而不是页面标题。
我想我需要写一个定制步行器。。我希望有人能帮我找到一个更简单的解决方案或代码片段。
默认情况下,wp\\u list\\u页面会显示一个无序的帖子标题列表。为了节省侧边栏菜单中的空间,我尝试创建一个页面段塞列表,而不是页面标题。
我想我需要写一个定制步行器。。我希望有人能帮我找到一个更简单的解决方案或代码片段。
我建议使用get_pages()
而不是wp_list_pages()
为此目的。
这个get_pages()
函数将返回页面的对象数组,您可以使用数组数据构建自己的HTML列表。e、 g.:
<?php
// Wrap in a function, for later output;
function wpse47989_list_pages() {
// Get an array of pages using default arguments
// See Codex for list of arguments
$wpse47989_pages = get_pages();
// Open the unordered list
$page_list = \'<ul>\';
// Loop through the results, and output an HTML list
foreach ( $wpse47989_pages as $wpse47989_page ) {
// Open the list item
$page_list .= \'<li>\';
// Open the link
$page_list .= \'<a href="\' . $wpse47989->permalink . \'">\';
// Link anchor text (post slug)
$page_list .= $wpse47989_page->post_name;
// Close the link
$page_list .= \'</a>\';
// Close the list item
$page_list .= \'</li>\';
}
// Close the unordered list
$page_list .= \'</ul>\';
}
?>
然后,当然,您只需在希望显示列表的任何位置输出函数。(注意:这将是一个很好的自定义小部件的候选者。您甚至可以传递函数get_pages()
参数作为小部件选项。)您可能需要操纵foreach输出以进行样式设置/等等。
嗨,谢谢你的阅读。我试着在后台抓住作者的鼻涕虫。get_the_author_meta( \'user_nicename\' ); 为空。我试图用谷歌搜索这个问题,但找不到关于如何处理后端的任何具体信息。任何提示都很好。我坚持写作以达到质量标准。很抱歉发送垃圾邮件,但这似乎是唯一的解决方案。叫它垃圾邮件,我叫它任何东西,但我不会抱怨,因为否则,什么愚蠢的文字会在这里结束,只是为了得到一点帮助。