Title: Conditional Shortcode problem
Last modified: August 20, 2016

---

# Conditional Shortcode problem

 *  [sagive](https://wordpress.org/support/users/sagive/)
 * (@sagive)
 * [14 years, 7 months ago](https://wordpress.org/support/topic/conditional-shortcode-problem/)
 * hey guys.. i am creating a shortcode that should return a specific image among
   other stuff depending on the user entered value
 * here it is:
 *     ```
       function postInfoBoxSc( $atts ) {
           extract( shortcode_atts( array(
               'subject' => 'Category type',
               'difficulty' => 'User Types',
               'completiontime' => 'completion Time'
           ), $atts ) );
   
       		// Set image acorring to guide type
       		if ($subject == 'wordpress') {
       			$subjectImg = '<img src="'.get_bloginfo('template_url').'/img/postInfoBox/wordpress.png" alt="מדריך וורדפרס" />';
       		} elseif ($subject == 'web design') {
       			$subjectImg = '<img src="'.get_bloginfo('template_url').'/img/postInfoBox/webDesign.png" alt="מדריך בניית אתרים" />';
       		} elseif ($subject == 'facebook') {
       			$subjectImg = '<img src="'.get_bloginfo('template_url').'/img/postInfoBox/facebook.png" alt="מדריך פייסבוק" />';
       		} elseif ($subject == 'RSS') {
       			$subjectImg = '<img src="'.get_bloginfo('template_url').'/img/postInfoBox/rss.png" alt="מדריך RSS" />';
       		}
   
           return '
       	<br class="clear" />
       	<div class="postInfoBox">
       		'. $subjectImg .'
       		<h5>Guide information:</h5>
       		<ul>
       			<li><strong>Category:</strong> '. $subject .'</li>
   
       					<li><strong>User Lever:</strong> '. $difficulty .'</li>
   
       					<li><strong>completion Time:</strong> '. $completiontime .'</li>
   
       		</ul>
       	</div>
       	';
       }
       add_shortcode( 'postInfoBox', 'postInfoBoxSc' );
       ```
   
 * No matter what i do the value for subject isnt being checkd..
    What am i doing
   wrong?

The topic ‘Conditional Shortcode problem’ is closed to new replies.

## Tags

 * [input](https://wordpress.org/support/topic-tag/input/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [user](https://wordpress.org/support/topic-tag/user/)

 * 0 replies
 * 1 participant
 * Last reply from: [sagive](https://wordpress.org/support/users/sagive/)
 * Last activity: [14 years, 7 months ago](https://wordpress.org/support/topic/conditional-shortcode-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
