Monday, December 30, 2019

WordPress Ke Text Widget Me PHP Kaise Use Kare

WordPress Ke Text Widget Me PHP Kaise Use Kare

Sometimes we have to exicute php in the text widget of our wordpress. But by default, wordpress does not advise us to run php in a text widget. So today we are going to tell you how to allow executing php in the text widget of wordpress. If you manually customize your blog, then this post will be very useful for you.
WordPress Ke Text Widget Me PHP Kaise Use Kare 1
Developers came to be the easiest after WordPress. Many years before today, when there was no wordpress, developers used to take a lot of time to design and build a site. But after the arrival of wordpress, it has become all easy. Now any developer creates his favorite site with the help of wordpress.
After the arrival of WordPress, developers have saved a lot of time. In today's time, wordpress is being used in almost every kind of website. The developer can easily design any kind of website using it.
People choose it the most because those who do not know coding, they also use it easily. If those who have knowledge of coding, then they can give a professional look to their site. In this, you can give your site a look according to you.
Well, if you want to create a blog or business website, then wordpress is the # 1 option for you. This has become the first choice not only by mine but by crores of people. However, it is a free cms but for this you have to spend money to buy hosting. Apart from this, there are many platforms that offer you hosting for free, but still people choose the most wordpress only.
If you have been using wordpress for a long time then you must have realized that it is very easy to customize the wordpress blog. If you know a little bit of php, html, css, javascript then you too will easily customize it.
In this post, I am going to tell you how to execute php in the text widget of wordpress? By default, you can use html, css in it but cannot use php. Often, we keep adding php widgets to our blog. In such a situation, sometimes we are also aware of using php in the text widget. So let's also know about it.
By default, WordPress does not allow us to use php in a text widget. If you want to run php in it, then its feature has to be enabled. You will be able to add php widget through a text widget in a widget area of ​​the site. You will be able to execute php in widget area like sidebar, footer, header.
For this you can also use PHP Text Widget or PHP Code Widget plugin. But the method that we will tell you below, you can do this manually also.
If you want to enable running php in the text widget of your wordpress blog, then for this a simple code has to be added to your theme's functions.php. After that you will be able to use php easily in the text widget.

First login to your blog, then Dashboard »Appearance» Editor By going to functions.php Open the file and add the following code to it.
 
 
 
 
function php_execute ($ html) {
if (strpos ($ html, "<"."?php")!==false){ ob_start(); eval("?".">". $ html);
$ html = ob_get_contents ();
ob_end_clean ();
}
return $ html;
}
add_filter ('widget_text', 'php_execute', 100); 
Now you Save changes Will have to click on the button.
After that you go to Appearance »Widgets and open the text widget and run some php code and check it. Like here am running The result of which I got something like this.
WordPress Ke Text Widget Me PHP Kaise Use Kare 2
In this way you can allow using php in the text widget in your WordPress blog. Now you can run many types of php widgets via direct text widget.

Hope you have liked this post and by reading this post you will have enjoyed it. If you have any questions related to this, then comment below and tell us. Do share this post in social media.

No comments:

Post a Comment