Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of running PHP code in WordPress text gadget

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to run PHP code in WordPress text gadgets. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

WordPress text gadget can add arbitrary HTML code, but the default PHP code added to the text gadget does not run, the following code is very useful!

Add the following code to the functions.php file for your current theme:

Add_filter ('widget_text',' php_text', 99); function php_text ($text) {if (strpos ($text,''. $text); $text = ob_get_contents (); ob_end_clean ();} return $text;}

After that, you can add a text gadget to the sidebar and enter the PHP function code into it to see if it works.

Previously recommended plug-in: MO Widgets can run PHP in a gadget, but the above code is more convenient and practical.

Thank you for reading! This is the way to run PHP code in the WordPress text gadget. I hope the above can be helpful to you, so that you can learn more knowledge. If you think the article is good, you can share it and let more people see it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report