Question:
Answer:
I'm following this tutorial on adding Google Content Experiments code to
header.php.
I added the following code to
header.php:<?php if (is_page('346') ):?>
<!-- Google Analytics Content Experiment code -->
...
<!-- End of Google Analytics Content Experiment code -->
<?php endif; ?>
This didn't produce the content experiment code on the front end. I tried:
<?php if (is_page(346) ):?>
<!-- Google Analytics Content Experiment code -->
...
<!-- End of Google Analytics Content Experiment code -->
<?php endif; ?>
This didn't work either.
Can you see why this code is not working? Thanks.
Answer:
A simpler solution will be to pass the
title or the slug as argument in is_page(). You won't have issues if you duplicate that page on another server.<?php
if (is_page( 'Page Title' ) ):
# Do your stuff
endif;
?>

Không có nhận xét nào:
Đăng nhận xét