Support » Themes and Templates » Modifying a Template, PHP help?

  • Hey guys!

    A member in my last topic refereed me to this template to get me started on viewing my categories in a specific way on the index page.

    I need to modify the code in the template so that I can provide alternate div wrappers around the post divs, unfortunately, this needs a little more php handling than I can manage.

    I figure an if statement would work, IF categoryid=1 then use this, if its not, use default. But I have no idea how to nest it or how to target the category I want it to check for, can anyone with php expertise help me out?

    If you can help me fix this, it’ll make my day, hey I’ll even help you with graphics to make this worthwhile.

    The Full Template Code.
    The snippet that needs editing:

    /* post loop for each category listing */
       foreach($posts as $post) :
       $category = get_the_category();
    // if post is in correct category
       if($current_cat == $category[0]->cat_ID) : ?>
    <div class="post" id="post-<?php the_ID(); ?>">
       <div class="entry"><?php the_content(); ?></div>
                endif; // end 'if post in correct category'
            endforeach; // end post loop
            rewind_posts(); // reset loop for next category
        endforeach; // end 'display by category' loop

Viewing 7 replies - 1 through 7 (of 7 total)
  • where would be the best place to go to hire someone to do something like this?

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    First, describing what it is that you’re actually trying to do might get better responses. I read your post and the associated code half a dozen times, but still can’t understand what it is that you actually want it to do.

    As for hiring somebody, the general place to look is the wp-pro mailing list:

    Sounds like you want to put a different div around the post depending on what category it is? it would be good to know exactly why so that people can tell you whether that’s the best way to achieve what you want to do.

    But … a few weeks ago I crafted my first conditional statement that allows for different background images in the headers over different blog categories, and I think that code could easily be modified to do what you want to do. The post explaining what i did is at

    I think all you’d have to do is to change the bit that says h3 class="entrytitle so that it referred to a div rather than an h3 tag and change “entrytitle” to match the class you want to use. You’d probably also want to use “id” instead of “class.” And all of that code would replace the opening “div” tag that you’re putting around the posts. You also have to set up the styles in your stylesheet, of course.

    I’d be happy to answer questions about how this works — it’s simpler than it looks.

    Sorry guys, got carried away with exams so I couldn’t check my post sooner, wish I did!

    What the template basically does is output the categories in groups, right?

    That’s perfect, except that my different categories must be displayed differently.

    This is because I have a category called Art, another called Photography and the last one is Post.

    I’m going to use the template for my index page, it’s going to display the excerpts for my categories, so when you hit my front page you’ll see;

    [thumb] [thumb] [thumb]

    [thumb] [thumb] [thumb]

    [title] – post snippet
    [title] – post snippet
    [title] – post snippet

    (where [thumb] and [title] link to the original post)

    To achieve the above result, I have to call different things depending on the category displayed, does that make more sense? I might add a fourth category that needs a different display style all together, so I wish the solution is scalable and not limited to just outputting two or three different styles per category.

    I hope this makes it much clearer. Sorry about that.

    That’s a *totally* different question from the first one! And I have to say I have no experience of photoblogs so I can’t be of help.

    Presumably you’ll be using some kind of plugin, and until you tell people what that is I can’t imagine you’re going to get much help from the forum.

    I’m not really looking to add more plugins, heh. I’m managing pretty good so far, my only tummble is with displaying a dynamic index page instead of just the most recent 10 in my categories.

    I’m pretty sure I can do it with this template code, I only need to figure out how provide alternate viewing styles for each category. erk. who knows, maybe it is really tough?

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Modifying a Template, PHP help?’ is closed to new replies.