• Resolved chappie

    (@chappie)


    Ho hum, it never rains but it pours.

    After a minor addition to my child functions.php, I now have the dreaded White Screen of Death. If someone can bail me out, I would be eternally grateful. If not, I’ll mow the lawn.

    Here’s what I was doing…

    Using @nikeo’s spiffing snippet to replace a slider call to action link with a custom URL (an anchor on the same page as the slider), I adapted it slightly by inserting “#anchor” instead of the full URL. Could this innocent piece of shorthand be the cause of my meltdown?

    The only other liberty I took was to link my slider button to a page which no longer exists in my menu, even though it still shows up in the slider image dropdown list of URL links. I assumed it wouldn’t matter since the snippet overwrites that URL anyway.

    But one, or both, of my actions have incurred the wrath of God. Unfortunately, I can’t get any of my site pages to load from history and nor can I access my dashboard.

    Is there a cure?

    These are the snippet instructions:

    You will need to replace the following texts in the snippet by your values :

    MY-IMAGE-ID => this is the WordPress id of the slider’s image for which you need to set the custom link. You can easily find it in the permalink of your media, on the edit screen.

    MY-CUSTOM-URL => this is your custom link. Ex : http://www.mywebsite.com

    …and here’s the php:

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2);
    function my_slide_custom_link( $slide_link , $image_id ) {
    	//does nothing if the image's id is not the targeted one
    	if ( MY-IMAGE-ID != $image_id )
    		return $slide_link;
    
    	//sets a custom url for the targeted slide
    	return 'MY-CUSTOM-URL';
    }

Viewing 14 replies - 1 through 14 (of 14 total)
  • Thread Starter chappie

    (@chappie)

    Should have added that I have already used this snippet once before and it has been working fine – although I didn’t take any liberties with that one.

    But you can revert your child-theme functions.php, right?
    Anyway enable the debug mode to see what happened:
    https://codex.wordpress.org/WP_DEBUG

    Thread Starter chappie

    (@chappie)

    Phew! Here comes the cavalry!

    Thanks d4z_c0nf – I did erase the new php snippet and re-save my functions.php file but I still have the WSOD.

    And as things stand, I can’t get in to revert to a previous version of the slider image edit page to see if my use of a non-existent URL as a placeholder (pending overwriting by the php snippet) was what did the damage.

    Thanks for the link. I’ve read the DEBUG codex but it’s above my pay grade. In short, I don’t know what to do next.

    Thread Starter chappie

    (@chappie)

    Should I try manually removing my child functions.php file temporarily – just to be sure that it is no longer the culprit?

    And if it’s possible to look in a text file to find the code I inserted via the slider image editor, maybe I could manually erase it?

    No it’s not above your pay grade 🙂
    Make a back-up of your wp-config.php, and open the non back-up file.
    You’ll see this lines:

    /**
    * For developers: WordPress debugging mode.
    *
    * Change this to true to enable the display of notices during development.
    * It is strongly recommended that plugin and theme developers use WP_DEBUG
    * in their development environments.
    */
    define('WP_DEBUG', false);

    change false with true
    That’s all 😛
    This way you’ll not see a WSOD but an php error which, more likely, should be something like a missing semicolon or end brace.
    Hope this helps, otherwise come back here 😛

    Thread Starter chappie

    (@chappie)

    Thanks d4z_c0nf – I can definitely do that and will report back.

    I do think that particular codex could have been written with newbies and virgins in mind — as you have now kindly translated.

    Thread Starter chappie

    (@chappie)

    Parse error: syntax error, unexpected end of file in /Applications/MAMP/htdocs/sitename/wp-content/themes/customizr-child/functions.php on line 105

    I’m saved! It was a missing end bracket 🙂

    Thanks for saving my life (again) and I’ll know what to do next time.

    If you would like somewhere to stay in Berkshire the next time you visit, just let me know. Or I could could write something for you. I’m a professional scribe.

    Dont’ grope me 😛
    Thank you so much for your kindness!

    Thread Starter chappie

    (@chappie)

    Are you based in Italy? Anywhere near Bari? My son is heading to Alberobello in a couple of weeks and I could load him up with stuff you might need in order to keep up your Customizr vigil, eg tea, Brandy, cigarettes, bacon, vitamins…you name it.

    Thread Starter chappie

    (@chappie)

    I’m back 🙂

    I have now reproduced my WSOD when trying to reinstate my slider call to action URL php snippet. Can anyone see why snippet 1 below works fine and yet snippet 2, inserted straight after snippet 1, gives me the WSOD?

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2);
    function my_slide_custom_link( $slide_link , $image_id ) {
    	//does nothing if the image's id is not the targeted one
    	if ( 2837 != $image_id )
    		return $slide_link;
    
    	//sets a custom url for the targeted slide
    	return 'http://localhost:8888/sitename/?page_id=171/#reviewform';
    	}
    
    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2);
    function my_slide_custom_link( $slide_link , $image_id ) {
    	//does nothing if the image's id is not the targeted one
    	if ( 2996 != $image_id )
    		return $slide_link;
    
    	//sets a custom url for the targeted slide
    	return 'http://localhost:8888/sitename/?page_id=19/#bourneend';
    }

    I have obviously double-checked the image ID numbers and the page URL but maybe I need an extra bracket somewhere? TIA.

    Thread Starter chappie

    (@chappie)

    …or is this just a one-time-only command which can’t be used on multiple sliders and different images?

    Yes I’m in Italy but I cannot accept your exquisite offer :). I’m really glad to help people like you, your kindness and your appreciation repay me enough! Also consider that before starting to attend this forum, my knowledge of wordpress was very limited, I am learning along with you.

    Back to your case the problems are two:
    1) You cannot re-declare the same functions two times
    2) You don’t need that 😀

    add_filter('tc_slide_link_url' , 'my_slide_custom_link', 10, 2);
    function my_slide_custom_link( $slide_link , $image_id ) {
    
        $image_links = array(
            '2837' => '?page_id=171/#reviewform',
            '2996' => '?page_id=19/#bourneend'
        );
    
        //does nothing if the requested image_id is not a key of the array
        if ( ! array_key_exists( $image_id, $image_links ) )
            return $slide_link;
    
        //else returns the custom link
        return 'http://localhost:8888/sitename/' . $image_links[$image_id];
    }

    Hope this helps.
    p.s.
    Thanks again.

    Thread Starter chappie

    (@chappie)

    Sorry to leave you hanging, d4z_c0nf – I had to go out after my last post.

    Your awesome array snippet works perfectly and my slider images are now linking to anchors without complaint. Thank you very much again for your help

    I think this little episode serves as a salutary reminder that those tempting php snippets can wreak havoc in the hands of a complete php novice.

    But I have learned some useful things today thanks to the awesome Customizr forum volunteers.

    Np.
    The debug mode enabled helps a lot 🙂
    Glad you solved.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘The dreaded White Screen of Death’ is closed to new replies.