WordPress.org

Ready to get started?Download WordPress

Forums

Homepage Header Text (5 posts)

  1. kashifamin
    Member
    Posted 7 years ago #

    Hi there,
    Could someone please help me with the following?

    I would like to place some intro text and an image to appear above my posts on the hompage of my site (www.bicentre.org.uk). I understand I need to use the is_home() tag, however I am unsure as to where this needs to be placed. My site has the following index.php

    <?php

    include_once('gravatar.php');

    get_header();
    ?>

    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <is_home()>

    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(17); ?>">" rel="bookmark"><?php the_title(); ?></h3>
    <div class="meta"><?php _e("Filed under:"); ?> <?php the_category(',') ?> — <?php the_author() ?> at <?php the_time('g:i a') ?> on <?php the_time('l, F j, Y') ?> <?php edit_post_link(__('Edit This')); ?></div>

    <div class="storycontent">
    <?php the_content(__('(Read on ...)')); ?>
    </div>

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

    <!--
    <?php trackback_rdf(); ?>
    -->

    </div>

    <?php comments_template(); ?>

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

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

    <?php get_footer(); ?>

    Any ideas?

  2. Zoutesnor
    Member
    Posted 7 years ago #

    I really don't have clue what you'd want to do, but the is_home() tag is normally used like this:
    if (is_home()){
    <!-- do stuff -->
    }
    else {
    <!-- do other stuff -->
    }

    The else part is not madatory though.

    Another thing, you've placed te is_home() tag in the loop of your index.php, normally you'd put it in header.php.

  3. kashifamin
    Member
    Posted 7 years ago #

    Thanks for the tips!
    (Sorry if I sound muddled, I am very new to WordPress and am a beginner with code!)

    Just to clarify my need, I have some text that introduces the website i.e. 'welcome to our website...etc' and a supporting image. I just want this text and image appear on the homepage first and all recent posts to appear beneath the text.

    Am I correct to be using the is_home() tag to achieve this?

    Is there another way?

  4. Zoutesnor
    Member
    Posted 7 years ago #

    No, the is_home tag is fine for this. Just put in your header.php, just before the <!-- end header --> code. Be sure to use the php tags, like this:
    <div id="content">
    <?php if (is_home()){ ?>
    <!-- Put your message here -->
    <?php } ?>

  5. kashifamin
    Member
    Posted 7 years ago #

    Thanks for this.

    You pointed me in the right direction. However, I found that it worked for me by placing the code in index.php just before the WordPress loop. This is what I did for reference:

    <?php // Welcome Text
    if ( is_home()
    ) { ?>

    My intro text....

    <?php } ?>

Topic Closed

This topic has been closed to new replies.

About this Topic