Support » Developing with WordPress » add_filter hook

  • Hello!
    I am very new to using hooks (new as in never done this before!). I have added a plugin by Curly Themes. I am using it for a client’s very large agenda. The layout of the agenda I want to use (Weekly Tabs) only displays the upcoming week. The developer provided an add_filter hook at the link below in section 8.2.6.

    http://docs.curlythemes.com/weekly-class-schedule/#free-support

    I have created a child theme, created the folders and file as directed and placed the code in the file (customized to my needs). Unfortunately, all I get is the actual code displayed on the screen.

    When I place the code in the PHP bracket the screen is just a white screen. I’m supposed to have this to the client this week and I am stumped! Any help/advice will be great. Below is the code I’m using:

    add_filter( 'wcs_start', 'myy_custom_start_date', 30, 2 );
    function myy_custom_start_date( $date, $options ){
     if( intval( $options['id'] ) !== 3 )
     return $date;
     return strtotime('10/17/2018'); 
    }
    add_filter( 'wcs_stop', 'myy_custom_stop_date', 30, 2 );
    function myy_custom_stop_date( $date, $options ){
     if( intval( $options['id'] ) !== 3 )
     return $date;
     return strtotime('10/22/2018'); 
    }
    • This topic was modified 6 months, 3 weeks ago by  bcworkz. Reason: code fixed
    • This topic was modified 6 months, 3 weeks ago by  Jan Dembowski.

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • It’s a very ahrd error to find, but it helps to have good code editor that will highlight everything. That lets you see where things are wrong.

    Oh, and when you’re developing, it’s a good odea to set WP_DEBUG to true in your wp-config.php file so that you can see errors like this. 🙂 Of ocurse, change it back to false when you take the site live.

    The error is with your single-quotes. They look fine- don’t they? Well, they aren’t. The second one is not an actual single-quote, but another different character (in this case a backtick) that looks like a quote, so it’s breaking on that. To illustrate where possible…

    This one is wrong:

    return strtotime ('10/17/2018′);

    This one is right:

    return strtotime ('10/17/2018');

    The difference is tiny, but that’s where the problem is.

    Moderator bcworkz

    (@bcworkz)

    adseamon – when you post code in these forums, please demarcate with `backticks` so it can be properly formatted. If you fail to do this, the forum’s parser corrupts your code and causes it to appear incorrect. I edited your topic to include backticks and the error catacaustic saw no longer exists.

    I do not see anything syntactically incorrect with the code you posted. Check your error log for additional clues to the cause of the white screen (AKA “WSOD” — white screen of death). Or as catacaustic suggested, define WP_DEBUG as true so the errors appear on your browser.

    I don’t know anything about your plugin, but I suspect the timestamp you are returning might be incorrect. Output the initial $date value to see what the expected format is supposed to be. It might possibly be YYYY-MM-DD instead of a timestamp. A wild guess on on my part. What the actual error is will confirm or deny my guess.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add_filter hook’ is closed to new replies.