Title: Modifying a Template, PHP help?
Last modified: August 18, 2016

---

# Modifying a Template, PHP help?

 *  [novice21](https://wordpress.org/support/users/novice21/)
 * (@novice21)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/)
 * Hey guys!
 * A member in my last topic refereed me to [this template](http://wordpress.org/support/topic/38046?replies=53)
   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](http://guff.szub.net/wp-content/sourceprt.php?file=home-dbc.php)
   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.](http://guff.szub.net/wp-content/sourceprt.php?file=home-dbc.php)
   
   The snippet that needs editing:
 *     ```
       <?php
       /* post loop for each category listing */
          foreach($posts as $post) :
          the_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>
       </div>
       <?php
                   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)

 *  Thread Starter [novice21](https://wordpress.org/support/users/novice21/)
 * (@novice21)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548067)
 * where would be the best place to go to hire someone to do something like this?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548069)
 * 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:
   [http://lists.automattic.com/mailman/listinfo/wp-pro](http://lists.automattic.com/mailman/listinfo/wp-pro)
 *  [Bodhipaksa](https://wordpress.org/support/users/haecceity/)
 * (@haecceity)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548070)
 * 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 [http://wordpress.org/support/topic/108768](http://wordpress.org/support/topic/108768?replies=1)
 * 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.
 *  Thread Starter [novice21](https://wordpress.org/support/users/novice21/)
 * (@novice21)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548097)
 * 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;
 * Art
    [thumb] [thumb] [thumb]
 * Photo
    [thumb] [thumb] [thumb]
 * Posts
    [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.
 *  [Bodhipaksa](https://wordpress.org/support/users/haecceity/)
 * (@haecceity)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548115)
 * 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.
 *  Thread Starter [novice21](https://wordpress.org/support/users/novice21/)
 * (@novice21)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548127)
 * 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?
 *  [charle97](https://wordpress.org/support/users/charle97/)
 * (@charle97)
 * [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548128)
 * [http://codex.wordpress.org/Category_Templates](http://codex.wordpress.org/Category_Templates)

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Modifying a Template, PHP help?’ is closed to new replies.

## Tags

 * [Alternate](https://wordpress.org/support/topic-tag/alternate/)
 * [Modify](https://wordpress.org/support/topic-tag/modify/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [style](https://wordpress.org/support/topic-tag/style/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 7 replies
 * 4 participants
 * Last reply from: [charle97](https://wordpress.org/support/users/charle97/)
 * Last activity: [19 years, 1 month ago](https://wordpress.org/support/topic/modifying-a-template-php-help/#post-548128)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
