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



首先,我对 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>

最新更新