我想使用WordPress做一个网站复制......所以,当观众来到http://www.wpsite.com/1005 ,我做一次检查(通过API),看看如果ID是一个有效的/主动代表,然后设置为平常的东西(姓名,电子邮件,REPID)一个cookie和重定向到主画面:
http://www.wpsite.com/wp/?page_id=34&id=1005
我现在这一切工作。
所以在这一点上,我想通过“ID = 1005”到所有的菜单链接在页面的顶部。 我的网站使用的是外观 - >菜单的功能在WordPress来建立菜单...
因此,当观众悬停/点击网站上的任何链接,我希望“&ID = 1005”被添加到它。 那可能吗? 如果用户有什么不适,也没有“&ID = 1005”? 谢谢。
亚当
更新:好吧,我创建了一个助行类,但我仍然感到困惑放在哪里查询字符串“ID”值,以便它显示在每一个:
// Walker Nav Menu
class description_walker extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args)
{
global $wp_query;
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$classes = empty( $item->classes ) ? array() : (array) $item->classes;
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
$class_names = ' class="'. esc_attr( $class_names ) . '"';
$output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
$attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
$attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
$attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
$attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
$prepend = '<b>';
$append = '</b>';
$description = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
if($depth != 0)
{
$description = $append = $prepend = "";
}
$item_output = $args->before;
$item_output .= '<a'. $attributes .'>';
$item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
$item_output .= $description.$args->link_after;
$item_output .= '</a>';
$item_output .= $args->after;
$output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
}
}
我有一种感觉它的“属性”部分中...与第三表达的东西......就像“如果没有ID‘’”添加此...但我失去了它...
任何帮助表示赞赏。
亚当