not show meta data on homepage, show on all others (2 posts)

  1. syncbox
    Posted 9 years ago #

    I am using index.php with an if else construction to change the order of how posts are displayed.

    if (is_home()) {
    else {

    just before the loop, which seems to work fine, except I want to NOT show the meta stuff for the home posts (which rarely change, won't be archived and are always by the same person, like intros to the categories)

    The loop I have looks like this:

    <div class="contentblock" id="post-<?php the_ID(); ?>">

    <h2>" rel="bookmark"><?php the_title(); ?></h2>

    <?php the_content(__('(more...)')); ?>

    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> @ <?php the_time() ?> <?php edit_post_link(__('Edit This')); ?></div>

    <div class="feedback">
    <?php wp_link_pages(); ?>
    <?php comments_popup_link(__('Comments (0)'), __('Comments (1)'), __('Comments (%)')); ?>


    <?php comments_template(); // Get wp-comments.php template ?>

    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>
    <?php endif; ?>

    <?php posts_nav_link(' — ', __('« Previous Page'), __('Next Page »')); ?>

    I'm not sure if this is what I'll stick with, but I would like to know if I should have separate loops or how to approach not having the meta (what cat, author, time, comments, etc) stuff if it is the home (cat=1)

    help appreciated. I tried searching and reading all posts in the how to section but I got to page 19 and gave up. And searching is just useless.

  2. justinbaeder
    Posted 9 years ago #

    It seems like you could just enclose your meta code inside the conditional statement:
    `<?php if (!is_home())
    echo '<div class="meta">' . _e("Filed under:") . the_category(',') . ' — ' . the_author() . ' @ ' . the_time() . edit_post_link(__('Edit This')) . '</div>';
    } ?>

    or something like that. (!is_home means "is not home page"). See
    for code samples with conditional tags.

Topic Closed

This topic has been closed to new replies.

About this Topic