This members-only tutorial provides the steps to register a custom “Is Archive” condition in Oxygen using which elements can be output (or not) only if the current page is an archive or not.
Install and activate Code Snippets plugin.
Go to Snippets > Add New.
Title: [Condition] Is Archive?
Code:
if ( function_exists( 'oxygen_vsb_register_condition' ) ) {
oxygen_vsb_register_condition(
// Condition Name.
'Is Archive?',
// Values: The array of pre-set values the user can choose from.
// Set the custom key's value to true to allow users to input custom values.
array(
'options' => array( 'true', 'false' ),
'custom' => false,
),
// Operators.
array( '==' ),
// Callback Function: Name of function that will be used to handle the condition.
'wpdd_is_archive_callback',
// Condition Category: Default ones are Archive, Author, Other, Post, User.
'Other'
);
}
/**
* Callback function to handle the condition.
*
* @param mixed $value Input value - true or false selected by the user.
* @param string $operator Comparison operator, =.
*
* @return boolean true or false.
*/
function wpdd_is_archive_callback( $value, $operator ) {
return 'true' === $value ? is_archive() : ! is_archive();
}
Apply the condition on the element(s) of your choice in the Oxygen editor.
The condition can be found under “Other” category.
Session expired
Please log in again. The login page will open in a new tab. After logging in you can close it and return to this page.