Run Specific Js on Specific page Wordpress

前端 未结 2 670
Happy的楠姐
Happy的楠姐 2020-12-29 00:23

I want to run a specific js on a specific page. I.e: wwww.custom.com/english/

I\'ve tried the following two codes (header.php and functions.php) but none of them wor

2条回答
  •  情话喂你
    2020-12-29 00:42

    There is multiple other ways.

    Just open your header.php and try to get current page slug or id and put simple if condition it will surely include your js

    Code 1

    global $post;
    $post_slug=$post->post_name;
    if($post_slug == 'about'){
    
    }
    

    OR Code 2

    $currentID= get_the_ID();
    //instead of 10 put the your id
    if($currentID == 10){
     
    }
    

提交回复
热议问题