Wordpress Nav Bar中的自定义短代码 [英] Custom shortcode in Wordpress Nav Bar

查看:57
本文介绍了Wordpress Nav Bar中的自定义短代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想在我的wordpress主题菜单栏中添加一个短代码按钮,以处理 bootstrap模态视图功能。

I just want to add a shortcode button to my wordpress theme menu bar for handle the bootstrap modal view function.

我尝试了'菜单中的短代码'插件,但它不起作用。我找不到菜单中短代码的替代插件,所以我安装了' Bootstrap 3 Shortcodes '插件,它创建了我想要的按钮和模态视图内容。但我无法在我的菜单栏中添加短代码。

I tried 'Shortcodes in Menus' plugin, but it doesn't work. I couldn't find alternative plugin for shortcodes in menu so I installed 'Bootstrap 3 Shortcodes' plugin, it created button and modal view content as i want. But I couldn't add shortcode to my menubar.

我努力尝试找到一些关于我的问题的答案。但遗憾的是不可能。

I did hard try to find some answer about my problem. But unfortunately could not.

这是由 Bootstrap 3 Shortcodes 插件生成的模态短代码;

Thats my modal shortcode generated by Bootstrap 3 Shortcodes plugin;

[modal text="Download Now" title="Veteriner Hekimlere Ulaşmanın En Kolay Yolu" xclass="btn btn-primary btn-lg"]
<p style="text-align: center;"><img src="http://web-test.vetmapp.com/wp-content/uploads/sites/2/2016/08/vetmapp-logo-withtext.png" alt="Logo" width="200" height="300" /></p>

<h4 style="text-align: center;">VetMapp'i cihazınıza göre aşağıdaki platformlardan cep telefonunuza ücretsiz olarak indirebilir ve hemen kullanmaya başlayabilirsiniz.</h4>
<p style="text-align: center;">
  <a href="https://itunes.apple.com/tr/app/vetmapp-acil-veteriner-klinikleri/id969463902?mt=8" target="_blank"><img src="http://web-test.vetmapp.com/wp-content/uploads/sites/2/2016/09/180x40xapple-store.png.pagespeed.ic.z0I7tHw8h6.png" alt="App Store'dan indir!" width="135" height="40" /></a>
  <a href="https://play.google.com/store/apps/details?id=com.esmobileinc.vetmapp&amp;hl=tr"
  target="_blank"><img src="http://web-test.vetmapp.com/wp-content/uploads/sites/2/2016/09/180x40xgoogle_play.png.pagespeed.ic.31v8JAmtbI.png" alt="Google Play'den indir!" width="135" height="40" /></a>
  <a href="https://www.microsoft.com/tr-tr/store/p/vetmapp/9nblggh4s3qm"
  target="_blank"><img src="http://web-test.vetmapp.com/wp-content/uploads/sites/2/2016/09/180x40xwindows_phone.png.pagespeed.ic.xvoiaCiuDP.png" alt="Windows Store'dan indir!" width="135" height="40" /></a>
</p>
[modal-footer] [button type="primary" style="border: solid 1px #18bda3; background-color: #fff; color: #18bda3;" link="#" data="dismiss,modal"]Kapat[/button] [/modal-footer] [/modal]

我只想使用 [modal text =立即下载title =VeterinerHekimlereUlaşmanınEnKolay Yoluxclass =btn btn-primary btn-lg] 进入 WP导航栏。

我该怎么做?我可以在functions.php中为此编写一个函数,或尝试其他方法吗?

How can I do this ? I can write a function in functions.php for this, or try some another approach ?

谢谢......

推荐答案

如果您分享您的短代码生成标记或您希望用您的短代码包装哪些标记,这对其他人来说是最好的理解。

If you share your shortcode generate markup or what markup you want to wrap with your shortcode that would be best to others understand clearly.

无论如何尝试它会顺利运行(测试)

anyway try this it will work smoothly (Tested)

add_filter( 'wp_nav_menu_items', 'wpse3967385_custom_menu_link', 10, 2 );

function wpse3967385_custom_menu_link( $items, $args ) {
   if ($args->theme_location == 'primary_nav') {
      $items .= '<li class="your-custom-item">' . do_shortcode( '[modal text="Download Now" title="Veteriner Hekimlere Ulaşmanın En Kolay Yolu" xclass="btn btn-primary btn-lg"]' ) . '</li>';
   }
   return $items;
}

随时更改您的菜单主题位置。

Feel free to change your Menu theme location.

希望有意义。

这篇关于Wordpress Nav Bar中的自定义短代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆