treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Wordpress Blog Posts Theme issue... (CSS targeting)

  • Seems simple enough...

    ~Here's your "Blog Post" now all I need to do is add a class with some styling and SHAZAM! I styled my blog posts to match my theme.~

    I am, however... missing something that I can't wrap my head around. I've researched and believe me... my google skillz iz dah BOMB! but no... can't seem to get it.

    My issue:
    -I'm just trying to finish up my custom theme. I'm down to styling (CSS) my blog posts. I want them to all be the same (not worried about styling them individually) -

    ie: I want all the "Titles" the same (color, font, etc....) / I want the content text the same / so forth and so on...


    Help Needed:

    I would love someone to enlighten me on how to go about doing so. I need to understand what I need to target with my CSS to style the posts them same.
  • Yeah man, I can tell you've got som mad Google skillz!

    What usually do is that I have a few standard classes when writing the markup.
    .post, .post-title, .post-meta, .post-body and so on. Implement these in the WordPress loop, and you're good to go.


    <div class='post'>
    <h2 class='post-title'>Title goes here</h2>
    <ul class='post-meta'>
    <li>1 comment, Written by Author</li>
    </ul>
    <div class='post-body'>
    <p>Content goes here.</p>
    </div>


  • I do appreciate the insight but I'm still having issues. I tried your approach and I have to be doing something wrong.

    Here's my PHP

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


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


    <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>


    <?php include (TEMPLATEPATH . '/inc/meta.php' ); ?>

    <div class="entry">
    <?php the_content(); ?>
    </div><!--END ENTRY--->

    </div><!--END POST--->


    Would someone be able to show me what to add in the PHP along with a "fake" CSS sheet of classes/ID's that would correspond to the PHP. I think that would give me a greater understanding of my mental block. Thanks Anton first off (Truly appreciate)! Also, thank you in advanced to any other peoples suggestions!
  • PHP Code
     <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>

    Outputs to HTML
    <h2><a href="#">Blog Title</a></h2>


    Therefore, you would target the h2{} and h2 a{} in your stylesheet to render all post titles.

    This is fairly basic, really. You should try the "view source" button to help you. Better yet, use firebug.