wp-cache -> keep sidebar dynamic? (4 posts)

  1. _ck_
    Posted 8 years ago #

    I've tried to use the examples given by wp-cache & staticize to keep functions dynamic, but I am unsuccessful at making it work.

    (wp-cache uses the same dynamic wrapper)

    All I get is an error "unknown function" when I try to wrap the function call for getsidebar

    <!--mfunc get_sidebar() -->
    <?php get_sidebar() ?>

    Can anyone tell me what I am doing wrong?

    In case there is a question why, I have already made my sidebar semi-static and want to keep a few things like the user login name and online stats always functional.

    Thanks for any assistance/ideas!

  2. Mark Jaquith
    WordPress Lead Dev
    Posted 8 years ago #

    When you have a WP-Cache/Staticize Reloaded cached hit, WordPress is not loaded. You do not have access to any WordPress functions. That's why the function is undefined. You can use PHP functions and any functions defined before WP load or within <!--mclude--> directives, but not WP functions. You'll have to recode your sidebar to work without WordPress if you want it to be always dynamic.

  3. _ck_
    Posted 8 years ago #

    Ah I get it now - especially once I realize the whole point of the cache is not to load the thousands of lines of wp code and plugins.

    I guess what I need to do is find a variable that detects if wp-cache is turned on but experiencing a dynamic page call and cut out any custom bits like displaying the logged in user's name.

    Actually it might be more complicated than that - without wordpress loaded how does it know who is about to comment on a post and display the entry form for logged in vs guest commenters? I guess it doesn't?

  4. _ck_
    Posted 8 years ago #

    In the end, for now, I've just hacked wp-cache to handle only my feeds. Rather easy to do and since the feeds represent the 3rd most requested pages on the site, it has to help the load to some measurable effect. I'll know soon enough!

Topic Closed

This topic has been closed to new replies.

About this Topic