• Hi

    since I am using WP Super Cache my redirect doesn’t work anymore.
    I am using two custom fields for optional defining a redirect adress to which the page can be redirected automatically.
    I have placed the following code in my themes page.php:

    // redirect via custom field
             global $post; // < -- globalize, just in case
             // redirect to any www adress
             if(get_post_meta($post->ID, 'redirect to www', true)) :
                     $redirect_field1 = get_post_meta($post->ID, 'redirect to www:', true);
                     wp_redirect(clean_url($redirect_field1), 301);
             // redirect to a specific ID
             elseif(get_post_meta($post->ID, 'redirect to id', true)) :
                     $redirect_field2 = get_post_meta($post->ID, 'redirect to id:', true);
                     wp_redirect(get_permalink($redirect_field2), 301);
             endif;
             // normaler WP Header
             get_header();

    It seems that the redirect to www adresses still work but when I input an id for the redirect the page is loaded which should be actually redirected. When I turn off Super Cache everything works fine!

    Any ideas?
    I would like to know if there is a workaround für my page.php
    oder maybe I can disable caching for specific pages by using a custom field input.

Viewing 8 replies - 1 through 8 (of 8 total)
  • It won’t work because that code isn’t executed on cached pages. See the FAQ entry on “Why doesn’t WP UserOnline, Popularity Contest, WP Postratings or plugin X not work or update on my blog now?” in the readme.txt

    Thread Starter Endolil

    (@zabdesign)

    Thank you for your reply.

    It means my method will obviously not work on cached pages. I think it can be the right way to exclude the pages from caching on which I want to redirect.

    Thread Starter Endolil

    (@zabdesign)

    I am not able to tell super-cache not to cache specific pages.

    Can you tell me what I have to write into the field for exclusion?
    I have a page with this URL:
    http://www.mypage.com/me/about.html

    I don’t know the right syntax.

    “about.html” should do it. Did you try that?

    Thread Starter Endolil

    (@zabdesign)

    it seems to work now …
    I don’t know why it seems that I was to stupid for this simple step.
    What you told me was the first thing I tried because I saw it on the option page.

    Anyway,
    thank you very much! 🙂

    The plugin is really great!

    Thread Starter Endolil

    (@zabdesign)

    … there are still some questions.

    I added /die-akademie/die-essenz.html to the textfield for the pages that shall not be cached and it works.

    You write in the option page:

    Add here strings (not a filename) that forces a page not to be cached.

    Why not a filename?
    I was wondering why there is an entry like this:

    index\.php

    What does the backslash means and is index\.php not a filename?

    Thread Starter Endolil

    (@zabdesign)

    … and one more:

    Do you see any way to avoid a page/post caching by PHP in any template file?

    I am working a lot with custom fields and I would like to control by custom fields if a page is going to be cached or not.

    Yeah, just write some code that checks for the custom field and set the constant DONOTCACHEPAGE. The page won’t be cached.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: WP Super Cache] Redirect via wp_redirect() and custom field doesn’t work with super cache’ is closed to new replies.