Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm working on my first wordpress blog site and I think I'm doing pretty good. This is my site so far but I need some help with a couple things as I'm not sure why this is happening. I've styled my blog the way I want to (with the clickable title and the dark red background for the "POSTED ON:" date stamp, however when I styled that, ALL my pages got that styling too (I only want that styling on the blog not).I want my pages to just look like regular pages. I understand CSS & HTML, and a SMALL bit of PHP but I'm not understanding why my index is picking up that styling. I do understand, through using firebug, that the styling class is the same as the blog posts but I don't want that. How do I change it is the only code on my index page is this...

<div id="main">
        <?php while ( have_posts() ) : the_post(); ?>
        <?php get_template_part( 'content', 'page' ); ?>
        <?php endwhile; // end of the loop. ?>
</div><!-- #main -->

I don't understand where it's picking the styling up and which php page to change it on. If anyone can help me I'd appreciate it.

@Brad Farleigh (or really anyone who can help me):

I made a copy of the index.php page and called is page.php

PAGE.PHP

<div id="main">

        <h1 class="entry-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>


    <?php if (have_posts()) : ?>
               <?php while (have_posts()) : the_post(); ?>    
               <?php the_content(); ?>
               <?php endwhile; ?>
     <?php endif; ?>

</div>

A referenced page in the index page like this.

<div id="main">


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

                <?php get_template_part( 'page' ); ?>


                <?php endwhile; // end of the loop. ?>


        </div><!-- #main -->

So my pages seem to be working the way I want them to. Calling the content and titles, however now when I got to my blog it's all messed up. Understandably content-page.php has to be called from somewhere but where?

I very much appreciate the help.

share|improve this question
    
does your theme have a content-page.php and why are you calling the template part 'page' on the index? –  Michael Apr 4 '12 at 11:26
    
you're iterating trough your posts in your index template, but within that loop you are including the page template which does the same loop again. This is probably causing infinite recursion because of WP's random global variables :) So, remove the loop from page.php (the "if" block) –  onetrickpony Apr 4 '12 at 18:02
    
I did that, but no luck. Still the same outcome. Any other ideas? It seemed like a reasonable answer. –  kia4567 Apr 4 '12 at 18:08
    
try choosing a different name for your custom template. "page" is a default template (used by pages) –  onetrickpony Apr 4 '12 at 18:10
    
No luck. I pointed the index.php to a mine.php page but it's still reacting the same. –  kia4567 Apr 4 '12 at 20:48
add comment

2 Answers

I think you just need to add your body "blog" class before your own css style like below:

.blog .entry-subtitle {
width: 100%;
height: 36px;
line-height: 36px;
letter-spacing: 1px;
color: white;
font-weight: normal;
font-size: 1em;
text-indent: 15px;
margin-top: -10px;
background-color: #761616;
text-transform: uppercase;
}

It should works.

share|improve this answer
    
Thanks. That removed the styles but I still have the post date there, however if I remove it, it removes the date from my blog too. They are both the same page I believe, do you know how I might separate these files into their own identity? I have edited my questions above, maybe you can see what I should be doing? –  kia4567 Apr 4 '12 at 17:51
    
Because your blog page's body tag has a class named "blog" that I found by Firebug. So simply you just need to add .bolg selector before every css style you want to add to your blog page. It will not affect other page. –  Tim Yao Apr 4 '12 at 23:59
    
Regarding the date box. You can define your own loop to get rid of this date box by using your own content-xxx.php. Also there is another easy way just use css style dispaly:none to hide the date box on all page. At the same time you can use the .blog selector to give a different style to blog page. –  Tim Yao Apr 5 '12 at 0:12
    
I got it working, thanks! –  kia4567 Apr 8 '12 at 3:27
add comment

By default wordpress will display posts and pages based on the layout defined in index.php but you can override these using the template heirarchy.

The wordpress template heirarchy is best explained here. Also, This is a great diagram which shows you what templates control website components.

You can check what page template can have control over a page by using firebug to inspect the class on your tag. For example your "wine law" page body tag currently has the class of "page page-id-67 page-template-default single-author" which shows that you could customise the layout using the page.php file (which would effect all 'pages'), or even create a page-67.php file which would control that page only, as "67" is the page ID.

To answer your question - you could duplicate the index.php file (it'll depend on your template though) and rename it 'page.php' then remove the part of the code that displays the section which is showing the date.

I hope that helps!

-Brad

share|improve this answer
    
I can't copy over my index.php page and change the the code that displays the date as it only has a reference to content-page.php (which is where all the code is and it dictates for the blog too). If I'm even understanding this at all might I be able to copy and past index.php, call it page.php, create a page.ph file and replace the <?php get_template_part( 'content', 'page' ); ?> with <?php the_content(); ?> ? –  kia4567 Apr 4 '12 at 17:35
    
Please see my edited question above. I've added a bit more. I appreciate the help Brad. –  kia4567 Apr 4 '12 at 17:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.