WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to add a tracking pixel for a Facebook ad to my Wordpress site. It should only be active for one blog post, not for every page on the site.

How can I get the script into the HEAD section for the specific post only?

share|improve this question

You can use the wordpress Conditional Tags

You can add something like this to your functions.php file:

is_single( 'your-post-slug' )
    add_action( 'wp_head', 'your_function_with_pixel' )

There are a number of different conditional tags you can use. And your-post-slug can be substituted with the post id as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.