• Hey all.

    <?
    if (is_page('4')) {
    ?>
    	<script type="text/javascript">
    	$(document).ready(function(){
    		$("dd:not(:first)").hide();
    		$("dt a").click(function(){
    			$("dd:visible").slideUp("fast");
    			$(this).parent().next().slideDown("fast");
    			return false;
    		});
    	});
    	</script>
    <?
    }
    ?>

    The JS <script> tag code above is displayed on EVERY page, when I only want it show when the page id is 4.

    Please help.

    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Try this:

    <?php if (is_page(4)) { ?>
    <script type="text/javascript">
    	$(document).ready(function(){
    		$("dd:not(:first)").hide();
    		$("dt a").click(function(){
    			$("dd:visible").slideUp("fast");
    			$(this).parent().next().slideDown("fast");
    			return false;
    		});
    	});
    	</script>
    <?php } else { ?>
    <?php } ?>
    Thread Starter sincewelastspoke

    (@sincewelastspoke)

    Brilliant – worked a treat.

    Many thanks iridiax!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘IF is_page <– error :(’ is closed to new replies.