Support » Themes and Templates » [Resolved] is_home() or is_front_page() and the loop

[Resolved] is_home() or is_front_page() and the loop

  • I have been doing some looking around, and experimenting with code from others on the forum, but I haven’t found anything yet that applies to my particular situation.

    I have my home page set to the blog, and the rest of my website done using static Pages (wordpress pages). I want the loop to show only on the blog (home page), and not on my static pages. I have been trying various tricks with the is_home() and the is_front_page() functions, but I’m really not much with php (yet!).

    It seems to me that I should be able to use a conditional with one of those two, and just put it around the loop code. But everything I try has failed.

    Could someone help me out?

    Here is my loop code (nothing fancy):

    <?php if (have_posts()) : ?>

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

    <?php the_date(”,'<h2>’,'</h2>’); ?>

    <div <?php post_class() ?> id=”post-<?php the_ID(); ?>”>
    <h3 class=”storytitle”>” rel=”bookmark”><?php the_title(); ?></h3>

    <div class=”meta”><?php _e(“Filed under:”); ?> <?php the_category(‘,’) ?> — <?php the_tags(__(‘Tags: ‘), ‘, ‘, ‘ — ‘); ?> <?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 (%)’)); ?>

    <div class=”post” id=”post-<?php the_ID(); ?>”>
    <div class=”entry”>
    <?php the_content(‘Read More »’); ?>

    <?php endwhile; ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi gman-1,

    I am not able to understand your issue. Do you want all blog posts on your home page? Like this
    1. http://pwdthecnology.zxq.net/
    2. http://praxis.ac.in/blog/



    Forum Moderator

    the loop is needed, even on static pages, to show the page content.

    if you want more control for pages, and your theme does not have a page.php, you could copy index.php and save it under the name page.php in your theme files.

    do you have a few links to your site to illustrate your problem?

    Chinmoy: It would be more like the praxis one if the blog were the homepage instead, but not so ambitious or busy… but I’m still not sure this is a good example…

    The problem right now is that the “About” page, the “contact us” page etc. have a big giant Date, Title, “Field under: “, category and comments status on them at the top. These make sense on a blog, but not on a static page. So my blog is the home page, and the rest (static pages) should not have that information on them.

    Alchymyth: Are you saying that if I make a page.php, it will pull from that instead of index.php for static pages Automagically? Because if that is the case, that would solve the problem right there…

    I just made the page.php and wow! That did it! Thank you! I don’t know how I missed that…

    Hi gman-1,

    First you create the ‘Blog’ page without any content. Then go to ‘your reading’ settings section. Setting the following option:

    A static page (select below)

    * Front page: About or your any static page
    * Posts page: Blog

    Hope it will help you.


Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘[Resolved] is_home() or is_front_page() and the loop’ is closed to new replies.
Skip to toolbar