Title: WP Super Cache Plugin ShortCode mfunc
Last modified: August 20, 2016

---

# WP Super Cache Plugin ShortCode mfunc

 *  [yannou974](https://wordpress.org/support/users/yannou974/)
 * (@yannou974)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/)
 * Hi,
    2 days i’m trying to use mfunc without success.
 * I’m using it inside my plugin developpement.
 * I’m using shortcode to make it appear in user-view.
 * Here is my code:
 *     ```
       <?php
       function XXX_get($atts, $content = null) {
       			?>
   
       <!--MFUNC return rand() -->
       <?php return rand(); ?>
       <!--/mfunc -->
   
       <?php
       }
   
       add_shortcode('XXX', 'XXX_get');
       ?>
       ```
   
 * My problem is, it returns always the same number.
    Never different.
 * Where is my problem ?
 * Thanks

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

 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159403)
 * Make MFUNC lowercase?
 *  Thread Starter [yannou974](https://wordpress.org/support/users/yannou974/)
 * (@yannou974)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159410)
 * already tried, but no 🙁
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159588)
 * Hi Donnacha,
    I try to the same: I’m using a shortcode to show adsense on specific
   positions in my posts. To protect my adsense account for getting “smart priced”
   I like to hide the ads for a few countries. I use this code:
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * I don’t get an error, but the ad content is still cached.
    Is it possible to 
   do this using short codes?
 * Thanks!
    `
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159589)
 * Take a look at the cached file in your cache directory and see what code it contains.
   Then load up wp-cache-phase1.php and trace what happens there. Look for “eval”
   which is the command that runs the cached file.
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159590)
 * Thanks Donncha,
 * do you got the chance to see my code?
    You say that it has to be possible to 
   use shortcodes for dynamic content parts?
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159591)
 * Olaf – I didn’t see it. Can you use a pastebin?
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159592)
 * sure here it is:
 * [http://pastebin.com/PdYTZTha](http://pastebin.com/PdYTZTha)
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159593)
 * What happens if you put the mfunc code directly in your theme? Or use a filter
   to filter the posts and insert the mfunc chunk of code that way?
 * I think the issue is that the mfunc string isn’t getting cached because the shortcode
   function “returns” the code output. You should probably return “<!–mfunc echo
   get_adsense() –>” etc, and not just return the output of get_adsense().
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159594)
 * That’s what I thought first how this works 🙂
    I will try this, thanks
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159595)
 * Donncha, using “echo” instead of “return” was the solution (time to write a tutorial
   about)
 * Thanks a lot!
 *  [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * (@finalwebsites)
 * [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159596)
 * Donncha, there is one tiny problem.
    If I place the shortcode inside the theme
   using do_shortcode it’s fine, but if I have the shortcode inside an article the
   generated code get moved to the begin of the content. I think it happens because
   I’m using the “echo” instead of the “return”. Any idea?
 * EDIT: looks like I was in trouble with my browser cache yesterday, it works with
   the code I posted [@pastebin](https://wordpress.org/support/users/pastebin/)

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

The topic ‘WP Super Cache Plugin ShortCode mfunc’ is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=1095422)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 11 replies
 * 3 participants
 * Last reply from: [Olaf Lederer](https://wordpress.org/support/users/finalwebsites/)
 * Last activity: [14 years, 2 months ago](https://wordpress.org/support/topic/wp-super-cache-plugin-shortcode-mfunc/#post-2159596)
 * Status: not resolved