Title: PHP help.
Last modified: August 19, 2016

---

# PHP help.

 *  Resolved [bryguy73](https://wordpress.org/support/users/bryguy73/)
 * (@bryguy73)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/php-help-5/)
 * This might be a snap, but I’m a n00b when it comes to php.
 * I wanted to post this topic in the advanced section, but you need to be a moderator
   to do so.
 * This is the script that I need to modify:
 *  <?php $aOptions = OnDemand::initOptions(false); ?>
    <?php if ( have_posts() ){
   the_post(); rewind_posts(); } if ( in_category($aOptions[‘sideblog-cat’]) ) {
   include(TEMPLATEPATH . ‘/category-blog.php’); } else { include(TEMPLATEPATH .‘/
   category-video.php’); } ?>
 * It’s a script used in a purchased WordPress theme. It currently directs visitors(
   based on their menu choice) to either the “category-blog.php” file or to the “
   category-video.php” file.
 * I need the above script to reflect 3 options. The third option would be “category-
   music.php”, so it would be “…blog.php” or “…music.php”, else “…video.php”.
 * I tried using “elseif”, but I didn’t have any success. Hopefully someone can 
   help me out based on the info provided. Let me know if you require additional
   info ;D

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

 *  Anonymous User
 * (@anonymized-3085)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/php-help-5/#post-1047893)
 * You probably want something like this:
 *     ```
       if ( in_category($aOptions['sideblog-cat']) ) {
       include(TEMPLATEPATH . '/category-blog.php');
       } elseif ( in_category($aOptions['sidemusic-cat']) ) {
       include(TEMPLATEPATH . '/category-music.php');
       } else {
       include(TEMPLATEPATH . '/category-video.php');
       }
       ```
   
 * but that assumes that **$aOptions** contains a **sidemusic-cat**
 * any help?
 *  Thread Starter [bryguy73](https://wordpress.org/support/users/bryguy73/)
 * (@bryguy73)
 * [16 years, 12 months ago](https://wordpress.org/support/topic/php-help-5/#post-1047916)
 * Thanks for the reply. I managed to figure it out just b4 I saw your reply. Here’s
   what I came up with:
 * <?php $aOptions = OnDemand::initOptions(false); ?>
    <?php if ( have_posts() ){
   the_post(); rewind_posts(); } if ( in_category($aOptions[‘sideblog-cat’]) ) {
   include(TEMPLATEPATH . ‘/category-blog.php’); }else if ( in_category(“7”) ) {
   include(TEMPLATEPATH . ‘/category-music.php’); }else{ include(TEMPLATEPATH . ‘/
   category-video.php’); } ?>
 * The important part was identifying the category id# for “music” which was “7”.
 * Thanks again
 *  [brookwarner](https://wordpress.org/support/users/brookwarner/)
 * (@brookwarner)
 * [16 years, 7 months ago](https://wordpress.org/support/topic/php-help-5/#post-1048084)
 * Hi there
 * I am still fairly new to PHP, so I was wondering if someone could tell me how
   to rewrite the following english into php?
 * IF customfield with key “addcontent” value = 1, show posts from category = 1.
   
   IF customfield with key “addcontent” value = 2, show posts from category = 2.
   etc etc…
 * The reasoning is this – i have a static area and a dynamic area on each page,
   and i would like to be able to pull the latest posts from a certain category 
   and display them only on the page that pertains to them. ie – Static area contains“
   all about bob”, dynamic area contains “bobs latest posts”.
 * This is possible with the blog_in_blog plugin, however i cant seem to make the
   plugin work with short codes.

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

The topic ‘PHP help.’ is closed to new replies.

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [elseif](https://wordpress.org/support/topic-tag/elseif/)
 * [menu](https://wordpress.org/support/topic-tag/menu/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [brookwarner](https://wordpress.org/support/users/brookwarner/)
 * Last activity: [16 years, 7 months ago](https://wordpress.org/support/topic/php-help-5/#post-1048084)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
