WordPress.org

Ready to get started?Download WordPress

Forums

Having trouble with a conditional statement (2 posts)

  1. benocav
    Member
    Posted 2 years ago #

    Hi Guys,

    I'm wanting to do something very simple but just can not seem to achieve it.

    I have been trying to use an if statement in my sidebar.php that will load a different post when on the Contact Page.

    In simple terms I need something like this...

    If page='contact-us'
    display (<?php
    $post_id = 44; // Get the Post ID
    $queried_post = get_post($post_id);

    echo $queried_post->post_content;
    ?>
    )

    else if
    display (

    <?php
    $post_id = 55; // Get the Post ID
    $queried_post = get_post($post_id);

    echo $queried_post->post_content; // Show the content of the Post
    ?>
    }

    I hope someone can help me...

    Cheers
    Ben

  2. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic