Title: Shortcode problem
Last modified: August 19, 2016

---

# Shortcode problem

 *  [bgcs3](https://wordpress.org/support/users/bgcs3/)
 * (@bgcs3)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/)
 * Hello!
 * I have a problem with this code:
 * <?php if (in_category(’59’)) { ?>
    <?php if function_exists(‘get_most_viewed’)):?
   > <?php }else { ?> <?php } ?>
 * If I put this into my archive.php it breaks down my site. But If is remove this
   line “<?php if function_exists(‘get_most_viewed’)): ?>” and I replace with some
   simple word, it works. The shortcode is for [http://wordpress.org/extend/plugins/wp-postratings/](http://wordpress.org/extend/plugins/wp-postratings/)
 * Could you tell me what is the problem?

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/#post-1974191)
 * the code does not really say what to do if the function exists.
 * maybe try:
 *     ```
       <?php if function_exists('get_most_viewed')): ?>
       do something html
       <?php echo get_most_viewed(); //or do something php ?>
       <?php endif; ?>
       ```
   
 *  Thread Starter [bgcs3](https://wordpress.org/support/users/bgcs3/)
 * (@bgcs3)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/#post-1974276)
 * Thank you but it does not work:(
 * Any ideas?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/#post-1974279)
 * is it possible that ‘get_most_viewed’ is actually not a function of this plugin?
 * i could not find it in any of the pages of the plugin [http://wordpress.org/extend/plugins/wp-postratings/](http://wordpress.org/extend/plugins/wp-postratings/)
 * where did you get the idea from?
 *  Thread Starter [bgcs3](https://wordpress.org/support/users/bgcs3/)
 * (@bgcs3)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/#post-1974309)
 * Sorry I wrote the wrong plugin. I use this one: [http://wordpress.org/extend/plugins/wp-postviews/faq/](http://wordpress.org/extend/plugins/wp-postviews/faq/)
   
   And I changed the code to:
 * <?php if (in_category(’59’)) { ?>
 * <?php if (function_exists(‘get_most_viewed’)): ?>
    -  <?php get_most_viewed(); ?>
 * <?php endif; ?>
    <?php }else { ?> <?php } ?>
 * And everything is OK:)

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

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

 * 4 replies
 * 2 participants
 * Last reply from: [bgcs3](https://wordpress.org/support/users/bgcs3/)
 * Last activity: [15 years, 3 months ago](https://wordpress.org/support/topic/shortcode-problem-6/#post-1974309)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
