WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
Mfunc does not work with slideshow (5 posts)

  1. erikhgm
    Member
    Posted 2 years ago #

    I am trying to make a dynamic slideshow in the header and figured I could use the mfunc functionallty to prevent the slideshow from being cached.
    But mfunc does not work. I get a "Unable to open file:/..." error
    This is the code:
    http://pastebin.com/HLhMwXPY

  2. tgeorge
    Member
    Posted 2 years ago #

    You mention "mfunc" (which is the right directive), but in the actual code, you've used "mclude" (which is a different directive). "mclude" is for loading external PHP files, like so:

    <!-- mclude -->path/to/file.php<!-- /mclude -->

    That's why you're getting an "Unable to open file" error. I replied with more details in your other thread :

    http://wordpress.org/support/topic/dynamic-content-1?replies=3#post-2317713

  3. erikhgm
    Member
    Posted 2 years ago #

    I removed the php tags and changed to mfunc and now the code looks like this: http://pastebin.com/kL96tswa

    and I have aslo tried this code: http://pastebin.com/pXCSg5yt

    I get this error code now its driving me crazy now nothing seems to be working

    Unable to execute code: $args = array( 'numberposts' => 1, 'orderby'=> 'rand', 'category' => 34 ); $rand_posts = get_posts( $args ); foreach( $rand_posts as

  4. tgeorge
    Member
    Posted 2 years ago #

    Well, there are still five <?php...?> tags in your "mfunc" code. Also, removing the <?php...?> tags is not as simple as deleting them. You also need to isolate the HTML tags, by putting them inside echo(...); functions.

    For example, original line :

    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>

    will become :

    echo('<a href="'); the_permalink(); echo('">'); the_title(); echo('</a></h5>');

    Sorry, but I don't have time to rewrite the entire code for you. You should be able to do it by yourself, by following the example I gave. Once you're finished, the entire section should look this :

    <?php
    <!-- mfunc -->
    ...
    <!-- /mfunc -->
    ?>
  5. Frederick Townes
    Member
    Plugin Author

    Posted 2 years ago #

    If your slideshow is dependent on WP itself it won't work in this way because W3TC runs before WP is loaded.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic