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

时间:2017-03-25 22:37:00

标签: javascript html css 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>

任何帮助都会受到赞赏,花了太多时间查找答案并发现与我正在尝试做的事情无关。

1 个答案:

答案 0 :(得分:0)

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

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