How to include php script into header for specific page in wordpress?

I want my script to load only in one certain post page in my blog.

Example page: www.name.com/this-is-cool-post/

Read More

How can i call my script if for example my script is in another .php file?

<?php if(is_page('this-is-cool-post')){ ?>
      <?php include("myscript.php"); ?>
<?php } ?>

this is not working for me and i don’t know where to problem is :S

Related posts

2 comments

  1. This may not be the most programmatic way of doing it, but how about creating a custom blog post template, call it blog-specific.php or whatever you want, add the following to the top of it:

    <?php
    /*
    Single Post Template: [Temp Name]
    Description: Description of template
    */
    ?>
    

    Then add your script (<?php include("myscript.php"); ?>) only to this template:

    You should then be able to change the template of a particular post in the Single Post Template dropdown option when editing a post:

    enter image description here

  2. I think the problem is the location of your script.

    If you work on a theme, try to include your script like this

    include get_template_directory() . "/path_to_ur_script/script.php";
    

    I hope that help u.

Comments are closed.