WordPress.org

Ready to get started?Download WordPress

Forums

If post/page id show.... (12 posts)

  1. jezThomp
    Member
    Posted 3 years ago #

    You can have if home page show so something....

    Is it possible to have if post id or page id, show the following....?

    So on page a you have banner a, on all other pages you have banner b.

    Is this possible, rather than having different includes for different pages?

    Many thanks :)

  2. Chantal Coolsma
    Member
    Posted 3 years ago #

    You can use is_page with a parameter:

    http://codex.wordpress.org/Function_Reference/is_page

  3. jezThomp
    Member
    Posted 3 years ago #

    Oh brilliant thanks..:)

    How would i go about adding some together?

    <?php
    is_page(42);
    
    show......
    
    is_post(10);
    
    show....
    
    everything else show....
    
     ?>

    That possible?

    :)

  4. Chantal Coolsma
    Member
    Posted 3 years ago #

    Depends on where the banner is placed ;-)

  5. jezThomp
    Member
    Posted 3 years ago #

    Well i was thinking whenever really....

    Or can it only be placed inside or maybe outside the loop?

  6. jezThomp
    Member
    Posted 3 years ago #

    Any help please?

    :)

  7. DigitalSquid
    Member
    Posted 3 years ago #

    <?php
    if(is_page(42)){
    
    Show something only for page 42 
    
    } else {
    
    Show something for all other pages
    
    }
    ?>

    You can use is_page() anywhere. It doesn't have to be in the loop.

  8. jezThomp
    Member
    Posted 3 years ago #

    Thank you but that doesn't work :(

    Get a syntax error.

  9. DigitalSquid
    Member
    Posted 3 years ago #

    Post the code you used...

  10. jezThomp
    Member
    Posted 3 years ago #

    <?php
    if(is_page(15)){
    
    contact page
    
    } else {
    
    rest of pages
    }
    ?>

    Also trying to do multiple ones but had no look either... :(

    <?php
    if(is_page(15)){
    
    contact page
    
    elseif(is_page(30)){
    
    book page
    
    } else {
    
    rest of pages
    }
    ?>
  11. jezThomp
    Member
    Posted 3 years ago #

    That wrong, or am i just missing something....?

  12. ryan4021
    Member
    Posted 2 years ago #

    try adding an } before elseif(is_page()){

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags