Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6711005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:05:18+00:00 2026-05-26T08:05:18+00:00

In WordPress, I have a page template that uses a specific JS file and

  • 0

In WordPress, I have a page template that uses a specific JS file and CSS file that no other part of the site uses. On this specific template page, is there any way to add these items to the head, before wp_head is called?

I realize I could use is_page_template() in a conditional but my head file is getting out of control.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:05:19+00:00Added an answer on May 26, 2026 at 8:05 am

    If you look here http://codex.wordpress.org/Plugin_API/Action_Reference you can see that the hook called just before wp_head is get_header

    So what you need to do is: add an action called on that hook, test if you are on the page that you want and if you are add the script and the css

    This would happen in a plugin (not in the theme files like header.php or functions.php) and it would look something like this:

    // call the function that adds your current script 
    add_action('get_header', 'add_that_script');
    function add_that_script()
    {
        if (is_page(SOME_PAGE_IDENTIFIER)) // this is the page you need; check http://codex.wordpress.org/Function_Reference/is_page on how to use this function; you can provide as a parameter the id, title, name or an array..
        {
            wp_register_script( 'mycustomscript', 'http://www.example.com/script.css'); // register your script 
            wp_enqueue_script( 'mycustomscript' ); // enqueue it to be added in the head section
    
            wp_register_style( 'mycustomstyle', 'http://www.example.com/example.css'); // register your css 
            wp_enqueue_style( 'mycustomstyle' ); // enqueue it to be added in the head section
        }
    }
    

    You just need to replace the id for your page and the urls to the js file and to the css. Sure, maybe you want to test some other way if you are on the right page, but I think that this shows the idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page template in wordpress that only shows posts from a specific
I have a wordpress blog. I made a custom page-template that allows users to
I have a wordpress-generated page where I need some posts (in a specific category)
I have a WordPress site (2.6.2) in which I have set the Home page
I have built a site in wordpress and the home page is really screwed
I have created a category template in Wordpress for all posts that are in
I am developing a WordPress page that uses a jquery.slideto.js navigation system and html
I'm building a Wordpress template from an HTML page. I currently have <?php $queried_post
I have a wordpress site with a large number of pages, each page represent
I have a wordpress site that I am using a child theme with. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.