admin管理员组文章数量:1318564
on our wordpress site we use utm_source in the querystring to determine the campaign that brought a customer to our site.
I need to dynamically add the passed utm_source from the initial page to all the menu items on the site. How can I modify all links in the wordpress menus to add the querystring variables?
on our wordpress site we use utm_source in the querystring to determine the campaign that brought a customer to our site.
I need to dynamically add the passed utm_source from the initial page to all the menu items on the site. How can I modify all links in the wordpress menus to add the querystring variables?
Share Improve this question edited Oct 19, 2020 at 17:36 afshin asked Oct 19, 2020 at 17:05 afshinafshin 1033 bronze badges 01 Answer
Reset to default 2Can be changed using filter
add_filter('wp_get_nav_menu_items', 'add_utm_to_links', 10, 3);
function add_utm_to_links($items, $menu, $args) {
foreach($items as $item) {
if(!empty($item->url)) {
$item->url .= strchr($url, '?') === false ? '?' : '&';
$item->url .= 'utm=value';
}
}
return $items;
}
本文标签: theme customizermodify menu item links dynamically
版权声明:本文标题:theme customizer - modify menu item links dynamically 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742049804a2418006.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论