39

How to Check if a URL Parameter Exists in Oxygen Builder

Powered by WPCodeBox

This Oxygen condition returns true if the given URL parameter is present.

This can be used, for instance, to add elements that are only visible if your URL includes a special URL parameter, like: https://example.com/?previewnewdesign.


<?php

add_action('plugins_loaded', function () {
    if (function_exists('oxygen_vsb_register_condition')) {

        global $oxy_condition_operators;

// Condition to check if a URL parameter is present.
        oxygen_vsb_register_condition('URL Param Exists', array('options' => array(), 'custom' => true), array('--'), 'oxy_url_param_exists_callback', 'Other');

        function oxy_url_param_exists_callback($value, $operator)
        {

            if ($_GET[$value]) {
                return true;
            } else {
                return false;
            }

        }

    }
});

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.