• johndove523

    (@johndove523)


    I’m a newb to WP and I am trying to style homepage posts (not loop) to be in their own container so as to give the posts some separation. Please see url: http://caspca.org/wordpress/ (look at the posts, “Volunteering, “Thank you for being a friend”). This post category has a slug of “home-page-article”

    Following what I could gather from Googling this issue, I:

    1. added this code to the functions.php file:

    /* Style Homepage Article Posts ********************************************/
    function the_category_unlinked($separator = ' ') {
        $categories = (array) get_the_category( 'home-page-article' );
    
        $thelist = '';
        foreach($categories as $category) {    // concate
            $thelist .= $separator . $category->home-page-article;
        }
    
        echo $thelist;
    }

    2. added this code to the single.php file:

    <div class="post<?php the_category_unlinked('home-page-article'); ?>">

    3. then on the homepage (named “template_home.php”), I’m not sure what to add in this code (if anything at all):

    <div class="eightcol">
    	<?php query_posts('cat=5'); ?>
    	<?php while (have_posts()) : the_post(); ?>
    	<h2><?php the_title(); ?></h2>
    	<?php the_content(); ?>
    	<?php endwhile; ?>
    
    	</div>
    	<?php get_sidebar(); ?>

    4. then the sytling is this:

    .row .eightcol .home-page-article {
    	background-color:#ebebeb;
    	padding:10px;
    	border:1px solid #CCC;
    	-moz-border-radius: 10px;
    	border-radius: 10px;
    	}

    I don’t know php very well at all (as I’m sure is obvious to you), if anyone can tell what I’m doing wrong, much appreciated. Thank you.

  • The topic ‘how to style individual category posts’ is closed to new replies.