How can I use is_page() inside a plugin?

后端 未结 3 1233
青春惊慌失措
青春惊慌失措 2020-12-18 07:48

I want my plugin to register a script only in a certain page.

For example, inside my plugin file I want to write something like this:

if (is_page())          


        
3条回答
  •  無奈伤痛
    2020-12-18 08:23

    You could use is_page() after template redirect so you need to add in the hook like this :

    add_action('template_redirect','your_function');
    function your_function(){
     if ( is_page('test') ) {
      // do you thing.
     }
    }
    

提交回复
热议问题