【发布时间】:2012-03-29 06:45:11
【问题描述】:
我正在尝试将页面中的自定义字段信息获取到导航菜单中。我以前遇到过这个问题...我只是不“了解”助行器菜单及其工作原理。
基本上,除了页面的标题,我想让它从自定义字段中输出图像的 URL 和图像描述,并创建一个链接到普通 WP 页面的菜单项。
在 nav-menu-template.php 文件中,我尝试通过像这样添加 get_post_custom_keys() 来修改 start_el 函数,但没有成功:
$item_output .= '<a'. $attributes .'>';
$item_output .= get_post_custom_values("product_image", $item->ID);
$item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after;
我也试过 get_post_meta();以及其他成功有限的人。我能做的最好的事情是通过指定一个硬整数值来获取在所有链接中重复的图像之一。或者,我已经能够让它在文本中输出正确的帖子/页面值,但没有图像。
任何人都知道解决方案..我做错了什么?
【问题讨论】:
-
有人吗?真的可以使用一些帮助。
标签: php wordpress menu custom-fields