• I am getting an error on amp pages:

    Undefined variable: cachedir in /wp-content/plugins/amp-cache/ampforwp-cache.php on line 305.

    Right now no amp pages are rendering. You can see this at https://stadivm.com/cc/.

    Please advise on how to solve this. There seem to be many such errors that I have encountered with AMPForWP and the cache plugin since using it. It is a great plugin, but these errors seem to be everywhere.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter fcadminn

    (@fcadminn)

    PS. You have to go to the page on a mobile phone.

    Thread Starter fcadminn

    (@fcadminn)

    Solved myself.

    For future reference for anyone else encountering this specific issue, I went to line 305 in that file, found where the function containing it begins, and added “global $cachedir;” just after the function statement on its own line.

    If this is a correct solution for your team, please add to the next update.

    Thread Starter fcadminn

    (@fcadminn)

    This did not solve the issue, but is only a temporary fix.

    After a short amount of time, 403 forbidden errors are thrown on all posts.

    Please provide a permanent fix for this issue.

    Plugin Author Ahmed Kaludi

    (@ahmedkaludi)

    Can you be specific on:
    1. what error you are getting exactly?
    2. where are you getting it?

    So I can understand and help you

    Thread Starter fcadminn

    (@fcadminn)

    I don’t know how I could be more specific. I answered both of your questions in my initial message.

    1. what error you are getting exactly?

    “Undefined variable: cachedir in /wp-content/plugins/amp-cache/ampforwp-cache.php on line 305.”

    “Right now no amp pages are rendering.”

    2. where are you getting it?

    “I am getting an error on amp pages”

    “You can see this at https://stadivm.com/cc”

    Thread Starter fcadminn

    (@fcadminn)

    Hey just a follow up on this, it would be great to get this solved and have my amp pages working on mobile again. Currently no mobile users can view my posts and are getting an error message.

    Thanks!

    Thread Starter fcadminn

    (@fcadminn)

    In case anyone is looking for a solution to this.

    Go to line 301 in /wp-content/plugins/amp-cache/ampforwp-cache.php, and edit this if statement:

    if($this->cachemod == ‘serverrewrite’){
    $cachedir=’ampforwp-cache/’;
    }

    .. to just this:

    $cachedir=’ampforwp-cache/’;

    This is probably a hacky solution, but my AMP pages are now working on mobile again and no doubt there will be a patch for this error at a later date.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Undefined variable: cachedir’ is closed to new replies.