The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

how to style individual category posts (1 post)

  1. johndove523
    Posted 4 years ago #

    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; ?>
    	<?php get_sidebar(); ?>

    4. then the sytling is this:

    .row .eightcol .home-page-article {
    	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.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.