• itonstandby

    (@itonstandby)


    DESIRED FUNCTIONALITY:
    I needed an easy way to prevent the Scroll Triggered Box from appearing on a specific page or post while leaving all other settings as is, without having to know the post ID number, category, slug, or other detail.

    SOLUTION:
    Please note that this solution only works on the Dreamgrow Scroll Triggered Box plugin v1.4. There is another plugin in the WordPress plugin directory of similar name and same version number. The solution outlined here will NOT work for that plugin because the source code is drastically different.

    To implement the solution requires a one time modification of the file dreamgrow-scroll-triggered-box/index.php. (This file can be accessed and edited through the WordPress plugin editor when logged in with an administrator login.)

    Open the plugin editor and select the Scroll Triggered Box plugin. Make sure you’re editing the file named above then scroll down to the function labeled stb_visible and find this section:

    // Show on frontpage
            if ($frontpage_id == $postID && isset($options['show']['frontpage']))
                return true;

    Add the following code immediately afterward:

    // BEGIN CUSTOM FIELD MODIFICATION
    	// THIS CODE LOOKS FOR THE CUSTOM FIELD stb_displaybox WITH A VALUE OF false
    	//  AND IF IT FINDS IT WILL STOP THE SCROLL BOX FROM DISPLAYING
    	$showme = get_post_meta($postID, 'stb_displaybox', true);
    	if ( ( ! empty($showme) ) && ( $showme == 'false' ))
    	    return false;
    	// END CUSTOM FIELD MODIFICATION

    Once the code is added, click the Update File button to save it.

    If an error message is displayed at the top of the screen after the Update File button is clicked, it is likely there is a typo or error in the code. Find and correct the error and click Update File again. It should say File Edited Successfully.

    MAKING IT WORK
    After the modification is made, edit the desired page or post and add a custom field named ‘std_displaybox’ and give it the value of ‘false’ (without the single quotes), update the page. Test the page to make sure the Scroll Box does not display.

    Note: If your scroll box settings are keeping the box from displaying on any page, it is likely because you’ve already closed the box before and the timer cookie is present on your computer. Either clear the browser cache or use a different browser or computer to check the functionality on the desired page.

    CAVEATS

    • This modification has only been tested on WordPress version 3.9.2. While it may work on previous versions and will most likely work on future versions, please do not assume that it will. TEST FIRST!!
    • The Frontpage settings will not be overridden by the addition of the custom field and value. If this needs to change, then add the code above the Show on Frontpage section rather than below it.
    • While it is possible to add more than one custom field of the same name to a page but with different values, only one occurrence of the std_displaybox field will be used.
    • This solution has not been fully vetted for conflicts with the plugin, themes, other plugins, older versions of WordPress, etc. So use at your own discretion and please test it thoroughly before concluding that all is well.
    • IMPORTANT: If there is a plugin update, or if the plugin is removed and readded, the code changes will be overridden and must be added back. Note: Any custom fields added to pages or posts will remain. Only the code must be added back to the plugin.

    https://www.ads-software.com/plugins/dreamgrow-scroll-triggered-box/

Viewing 1 replies (of 1 total)
  • Thread Starter itonstandby

    (@itonstandby)

    The OCD in me requires that the code be made a little neater. (Remove spaces) So here it is. Note there is no difference between this code and the original above. It’s just neater.

    // BEGIN CUSTOM FIELD MODIFICATION
    // THIS CODE LOOKS FOR THE CUSTOM FIELD stb_displaybox WITH A VALUE OF false
    //  AND IF IT FINDS IT WILL STOP THE SCROLL BOX FROM DISPLAYING
    $showme = get_post_meta($postID, 'stb_displaybox', true);
    if ( ( ! empty($showme) ) && ( $showme == 'false' ))
        return false;
    // END CUSTOM FIELD MODIFICATION
Viewing 1 replies (of 1 total)
  • The topic ‘[SOLVED] Keep Box From Displaying On Specific Posts or Pages’ is closed to new replies.