WordPress.org

Ready to get started?Download WordPress

Forums

Need help on creating If-statement in WordPress (2 posts)

  1. jtarr523
    Member
    Posted 2 years ago #

    I'm using WordPress. I have a movie review website called http://filmblurb.org. For my blog posts, I'm trying to create posts with different categories. Under the "Reviews" category, I have a "Details" box that serves as meta information for all my reviews. The problem is when I try to create a post that has the category of "Features" or something else, that "Details" box still remains. Basically, I want to try to create a PHP if statement that will only return the following code sequence when I only write a "Reviews" post. I'm using the "get_post_meta" tag in WordPress to fill in this "Details" box for every "Reviews" post I write. A sample post can be found here: http://www.filmblurb.org/reviews/97. Can anybody help me on this? I would appreciate it. Let me know if I need to explain more.

    <div class="box">
        <div class="boxheader">Details</div>
        <div class="text">
        <h1>Genre</h1>
        <p><?php echo get_post_meta($post->ID, 'genre', true); ?></p>
        <h1>Rated</h1>
        <p><?php echo get_post_meta($post->ID, 'rated', true); ?></p>
        <h1>Release Date</h1>
        <p><?php echo get_post_meta($post->ID, 'releasedate', true); ?></p>
        <h1>Runtime</h1>
        <p><?php echo get_post_meta($post->ID, 'runtime', true); ?></p>
        <h1>Director</h1>
        <p><?php echo get_post_meta($post->ID, 'director', true); ?></p>
        <h1>Cast</h1>
        <p><?php echo get_post_meta($post->ID, 'cast', true); ?></p>
        <h1>Grade</h1>
        <p><?php echo get_post_meta($post->ID, 'grade', true); ?></p>
        </div>
    </div>
  2. vjpo
    Member
    Posted 2 years ago #

    <?php if ( in_category( 'reviews' )) { ?>
    	<div class="box"></div>
    <?php } ?>

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

Topic Closed

This topic has been closed to new replies.

About this Topic