gpt4 book ai didi

javascript - 在导航菜单中放置缩略图而不是文本 (Wordpress)

转载 作者:行者123 更新时间:2023-11-28 04:04:29 24 4
gpt4 key购买 nike

首先,我对 php 和 html 总体上还很陌生,但我有一个函数可以找到页面的父页面并检索该页面的所有子页面并将其显示为页脚菜单。我想要做的是将页面缩略图(特色图片)显示为该页面的超链接,而不是该页面的标题。现在这是我拥有的与此菜单对应的代码:

// Get Top Ancestor
function get_top_ancestor_id() {

global $post;

if ($post->post_parent) {
$ancestors = array_reverse(get_post_ancestors($post->ID));
return $ancestors[0];

}

return $post->ID;

}
div.foot-wrapper {
display: -webkit-flex;
display: flex;
-webkit-flex-direction: row;
flex-direction: row;
-webkit-justify-content: center;
justify-content: center;
align-items: center;
flex-wrap: wrap;
width: 100%;
height: auto;
border: 1px dotted #efefef;
}
<div class="foot-wrapper">	
<nav class="site-nav-child children-links clearfix">

<ul>
<?php

$args = array(
'child_of' => get_top_ancestor_id(),
'title_li' => ''
);

?>

<?php wp_list_pages($args);?>

</ul>

</nav>
</div>

任何帮助将不胜感激,花了太多时间寻找答案并没有找到与我正在尝试做的事情相关的内容。

最佳答案

如果您的问题是添加缩略图并使其可点击类别,我认为这会有所帮助,在循环中运行。

<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

关于javascript - 在导航菜单中放置缩略图而不是文本 (Wordpress),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43022751/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com