Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

i want to use if and else statement on iframe but it's not working if and else statement not working on the iframe php page

<?php 

if("p=947"){
?>
 <iframe width="820px" height="1200px" style="overflow:hidden;margin-left:-900px; margin-top:-100px" allowtransparency="true" frameborder="0" src="<?php bloginfo ("template_url")?>/gallery/karachigallery.php" ></iframe>

<?php } else if("p=953") {?>
    <?php }?>
share|improve this question
    
what are you trying to test with the if statement? –  Michael Dec 10 '12 at 14:16
    
Navigate through this Stack archives, you'll see lots of examples of working code. –  brasofilo Dec 10 '12 at 14:38
    
This appears to be a PHP syntax question, not a WordPress question. –  Chip Bennett Dec 10 '12 at 15:06
    
@ChipBennett i'm using wordpress –  edgematrix Dec 10 '12 at 16:39
    
"I'm using WordPress" - Please refer to the FAQ: Note that we do not handle questions... not specific to WordPress (even if they happen in its context)... If your question is specific to WordPress, you need to edit it to indicate how it is specific to WordPress. As-written, it's simply a question of a PHP conditional clause. –  Chip Bennett Dec 10 '12 at 17:11

1 Answer 1

To test for a post id use get_the_ID():

if ( 947 == get_the_ID() )
{
    // do something
}

If you need it outside of a loop you can access the post object’s ID member:

if ( 947 == $post->ID )
{
    // do something
}
share|improve this answer

Your Answer

 
discard

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.