• 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)
  • Make MFUNC lowercase?

    Thread Starter yannou974

    (@yannou974)

    already tried, but no ??

    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. Please use the pastebin]

    I don’t get an error, but the ad content is still cached.
    Is it possible to do this using short codes?

    Thanks!
    `

    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.

    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?

    Olaf – I didn’t see it. Can you use a pastebin?

    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().

    That’s what I thought first how this works ??
    I will try this, thanks

    Donncha, using “echo” instead of “return” was the solution (time to write a tutorial about)

    Thanks a lot!

    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

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘WP Super Cache Plugin ShortCode mfunc’ is closed to new replies.