我正在一個網站的菜單上列出所有頁面有一個特定的菜單,並加載標題和自定義字段圖像與「高級自定義字段」 我可以顯示標題但是當我嘗試顯示所有的菜單上從當前頁面會顯示自定義字段圖像的圖像鏈接自定義字段的WordPress的列表頁面
下面是一個例子「http://appelhat.dk/bordplader/」菜單,當鼠標觸及頁面的BUTTOM向上移動。
下面是代碼
<nav id="main-navigation">
<ul>
<?php
$template = 'gallery.php';
$Pages = $wpdb->get_col("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_page_template' AND meta_value = '$template'");
foreach($Pages as $Page) {
$exclude_Pages .= $Page . ',';
}
$pages = get_pages("include=$exclude_Pages");
foreach ($pages as $page):
$title = $page->post_title
?>
<li>
<a href="<?php echo get_page_link($page->ID); ?>">
<span class="title"><?php echo $title ?></span>
<?php
$attachment_id = get_field('front_billede');
$size = "thumbnail";
$image = wp_get_attachment_image_src($attachment_id, $size);
?>
<img src="<?php echo $image[0]; ?>" />
</a>
</li>
<?php endforeach; ?>
</ul>
</nav>
感謝
得益於它完美地工作 – MyRevenge 2013-02-10 05:39:38