Support » Fixing WordPress » Why is same CSS inside same php file is enforced 2 different ways?

  • ajs


    I do not have an archive.php page, so my index.php doubles as the archive template. Also, I created a search.php page that is identical to the index.php except it says “Search Results..” at the top.

    My question is that the index.php page enforces the <div class=”entry entry-1″ while when called as an archive, or when duplicated in search.php, this <div> class does nothing, yet I can remove the class call altogether and it clearly effects the format, so somehow there is something going on in the php code to tell the page that it is indeed an index only that is being called to enact the <div> class:

    <?php get_header(); ?>
    <div id=”content”>
    <?php if (have_posts()) :?>
    <?php $postCount=0; ?>
    <?php while (have_posts()) : the_post();?>
    <?php $postCount++;?>
    <div class=”entry entry-1″>
    <div class=”entrytitle”>

    Any idea why that <div class=”entry entry-1″> only actually shows the class when viewed as an index? The archive page understands and utilizes all the postCount stuff too, just doesn’t behave the “entry entry-1” class. Very confused on this one.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ryan Fitzer


    Have you looked in header.php for any conditional statements?



    ah, didn’t think to check there. i found this:

    <body <?php if(is_home()){echo ‘id=”home”‘;}?>>

    which perhaps would have an effect on a <div> inside the <body>.. ?

    also found this, before the above code:

    <?php wp_head(); ?>

    any idea what that command does?



    ah, indeed, my styles says:

    body#home .entry-1

    so that explains it! another question resolved! thanks!



    Perhaps you can mark it resolved, then?

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Why is same CSS inside same php file is enforced 2 different ways?’ is closed to new replies.