How to use is_single, is_category, is_page WordPress Within a Plugin

On this article, I try to write it in english version and sorry for my bad english.

I just want to share my experince about How to use is_single, is_category, is_page WordPress Within a Plugin. I still newbie on wordpress and try to make simple plugin for my site. On my plugin, I should use some of wordpress function like get_posts, get_the_category, is_single and is_category. All get wordpress functions are work well, but is_ wordpress functions give me some error. Hmmm….

I have been search a couple of days to find out for this issue, but on some of articles that I have read are not to clear how to use is_single, is_category and etc within a plugin. I studied some of documentations from wordpress and also some articles from google about this issue. And now I will share the simple way to make it work!!.

First of all, to use is_ wordpress function we need include wp-load.php to our plugin. But don’t try to include it as:

We must do it with ajax handler. So on your plugin display function, please copy and paste this code:

Then on your function.php, use code below:

And try to access this page:

if this page returning blank page, that means it is work!!
Than you can use is_single, is_category, is_page and etc on your own plugin.

Okay.. That’s all for this article and hope it can helps. Thanks

Share di:   Email this to someone Share on Facebook Tweet about this on Twitter Share on Google+ Share on LinkedIn

Tinggalkan Komentar: