Title: Exclude Post Categories From Template File Using PHP Function
Last modified: August 22, 2016

---

# Exclude Post Categories From Template File Using PHP Function

 *  [dancappdesign](https://wordpress.org/support/users/dancappdesign/)
 * (@dancappdesign)
 * [11 years, 5 months ago](https://wordpress.org/support/topic/exclude-post-categories-from-template-file-using-php-function/)
 * I’ve been searching these forums and elsewhere for a couple of hours to no avail,
   yet I don’t feel my problem is a particularly complex one.
 * I have two blog pages on my site and 2 post categories. I want all posts from
   one category appearing on one blog and the other category on the other blog.
 * The two blogs are each a different template file, so the solution which is readily
   available on various tutorial sites – adding custom PHP to the functions.php 
   file – is not sufficient (because the functions.php file won’t ‘redeclare’ the
   same function twice with a different variable each time).
 * So I believe what I need to do is add the code which will exclude the necessary
   category directly into each of the two blog template files.
 * Can anyone help with the necessary code and its positioning?
 * Many thanks.

The topic ‘Exclude Post Categories From Template File Using PHP Function’ is closed
to new replies.

## Tags

 * [categories](https://wordpress.org/support/topic-tag/categories/)
 * [category](https://wordpress.org/support/topic-tag/category/)
 * [exclude](https://wordpress.org/support/topic-tag/exclude/)
 * [functions](https://wordpress.org/support/topic-tag/functions/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 0 replies
 * 1 participant
 * Last reply from: [dancappdesign](https://wordpress.org/support/users/dancappdesign/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/exclude-post-categories-from-template-file-using-php-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
