Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Warning: file_exists(): open_basedir restriction in effect. File(/var/www/efs/wp-content/plugins/memcached-is-your-friend/memcached-class-object-cache.php) is not within the allowed path(s): (/www/logichop_469/public:/www/logichop_469/mysqleditor:/www/logichop_469/web:/www/logichop_469/deploy:/www/logichop_469/deployment:/www/logichop_469/deployments:/www/logichop_469/tmp:/usr/share:/tmp:/dev/urandom) in /www/logichop_469/public/wp-content/object-cache.php on line 50

Deprecated: Return type of WP_Theme::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 554

Deprecated: Return type of WP_Theme::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 595

Deprecated: Return type of WP_Theme::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 535

Deprecated: Return type of WP_Theme::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-theme.php on line 544

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-includes/comment-template.php on line 1745

Deprecated: Return type of WP_REST_Request::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 960

Deprecated: Return type of WP_REST_Request::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 980

Deprecated: Return type of WP_REST_Request::offsetSet($offset, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 992

Deprecated: Return type of WP_REST_Request::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/rest-api/class-wp-rest-request.php on line 1003

Deprecated: Return type of WP_Block_List::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 151

Deprecated: Return type of WP_Block_List::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 175

Deprecated: Return type of WP_Block_List::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 164

Deprecated: Return type of WP_Block_List::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 186

Deprecated: Return type of WP_Block_List::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 138

Deprecated: Return type of WP_Block_List::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 75

Deprecated: Return type of WP_Block_List::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 89

Deprecated: Return type of WP_Block_List::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 110

Deprecated: Return type of WP_Block_List::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 127

Deprecated: Return type of WP_Block_List::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-includes/class-wp-block-list.php on line 199

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/wp-tools-gravity-forms-divi-module-premium/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Return type of Gravity_Forms\Gravity_Forms\External_API\GF_API_Response::jsonSerialize() should either be compatible with JsonSerializable::jsonSerialize(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/external-api/class-gf-api-response.php on line 179

Deprecated: version_compare(): Passing null to parameter #1 ($version1) of type string is deprecated in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/addon/class-gf-addon.php on line 5755

Deprecated: Return type of GF_Field::offsetExists($offset) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 93

Deprecated: Return type of GF_Field::offsetGet($offset) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 99

Deprecated: Return type of GF_Field::offsetSet($offset, $data) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 108

Deprecated: Return type of GF_Field::offsetUnset($offset) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /www/logichop_469/public/wp-content/plugins/gravityforms/includes/fields/class-gf-field.php on line 117

Warning: The magic method AffiliateWP_Allow_Own_Referrals::__wakeup() must have public visibility in /www/logichop_469/public/wp-content/plugins/affiliatewp-allow-own-referrals/includes/class-affiliatewp-allow-own-referrals.php on line 131

Deprecated: Creation of dynamic property Cookie_Law_Info_Cli_Policy_Generator::$plugin_name is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/admin/modules/cli-policy-generator/cli-policy-generator.php on line 176

Deprecated: Use of "self" in callables is deprecated in /www/logichop_469/public/wp-content/plugins/cookie-law-info/includes/class-cookie-law-info.php on line 606

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 67

Warning: Private methods cannot be final as they are never overridden by other classes in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/packages/kirki-framework/compatibility/src/Control.php on line 103

Deprecated: Creation of dynamic property Kirki\Compatibility\Framework::$modules is deprecated in /www/logichop_469/public/wp-content/plugins/df-gravityforms-divi-plugin-premium/kirki/kirki.php on line 68

Deprecated: Optional parameter $text declared before required parameter $cart_item_key is implicitly treated as a required parameter in /www/logichop_469/public/wp-content/plugins/logichop-subscription-conduit/logichop-subscription-conduit.php on line 323

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$customizations is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 136

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_subscribe_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 153

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_smtp_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 154

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_template_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 156

Deprecated: Creation of dynamic property WC_Sendinblue_Integration::$ws_sms_enable is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-sendinblue-newsletter-subscription/woocommerce-sendinblue.php on line 157

Deprecated: Creation of dynamic property WOO_SL_functions::$query_vars is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.functions.php on line 35

Deprecated: Creation of dynamic property WOO_SL::$licence is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-software-license/include/class.sl.php on line 21

Deprecated: Creation of dynamic property WCS_Retry_Admin::$setting_id is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce-subscriptions/includes/payment-retry/admin/class-wcs-retry-admin.php on line 22

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 66

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/SchemaController.php on line 69

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/packages/woocommerce-blocks/src/StoreApi/RoutesController.php on line 86

Deprecated: Creation of dynamic property wpdb::$payment_tokenmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$order_itemmeta is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_product_meta_lookup is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_tax_rate_classes is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Creation of dynamic property wpdb::$wc_reserved_stock is deprecated in /www/logichop_469/public/wp-includes/wp-db.php on line 668

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/wc-core-functions.php on line 1705

Deprecated: Creation of dynamic property WooCommerce::$api is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/includes/class-woocommerce.php on line 554

Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Internal/DownloadPermissionsAdjuster.php on line 157

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderTableMigrator.php on line 25

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderAddressTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderAddressTableMigrator.php on line 42

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostToOrderOpTableMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostToOrderOpTableMigrator.php on line 26

Deprecated: Creation of dynamic property Automattic\WooCommerce\Database\Migrations\CustomOrderTable\PostMetaToOrderMetaMigrator::$table_names is deprecated in /www/logichop_469/public/wp-content/plugins/woocommerce/src/Database/Migrations/CustomOrderTable/PostMetaToOrderMetaMigrator.php on line 43
Logic Hop Conditional CSS - Logic Hop

Logic Hop Conditional CSS

Quick Reference

Overview

Logic Hop provides a number of ways to implement conditional logic for content personalization. Conditional CSS is a powerful tool in which CSS is dynamically generated based on an individual user’s actions.

Logic Hop Conditional CSS is generated prior page load and is derived from the condition name using the WordPress slug.

For example, if a condition named Today is Friday was met, a CSS class is added to the body class attribute:

<body class="lh-today-is-friday">

And a CSS stylesheet is generated with the following styles:

.logichop-today-is-friday { display: block !important; }
.logichop-not-today-is-friday { display: none !important; }

If the Condition is not met, the body class attribute would not contain the CSS class and the CSS stylesheet would have the following styles:

.logichop-today-is-friday { display: none !important; }
.logichop-not-today-is-friday { display: block !important; }

Note: Conditional CSS can be used with cache plugins. Conditional CSS rules are generated when the page is loaded and are not cached.

Tutorial

Enabling Conditional CSS

  • Step 1
    • Select a Logic Hop Condition
  • Step 2
    • Copy the CSS class
  • Step 3
    • Check the option Enable Conditional CSS
  • Step 5
    • Click Update to save the condition

Congratulations! Your condition will now be evaluated on page load.

Note: All Conditional CSS enabled conditions are evaluated prior to each page load. While Logic Hop is extremely fast, it is recommended to only enable Conditional CSS for conditions which rely on this functionality.

Using the CSS Body Class

The CSS Body Class is added to the body class attribute when the condition is met. By default the class is added when the page is loaded. When Javascript Tracking is enabled, the class is added via jQuery after the page loads. This allows the CSS Body Class to work with page caching plugins.

The CSS class name is derived from the condition name using the WordPress slug. For example, if a condition named Today is Friday was met, the slug would be prepended with lh- and added to the class attribute as:

<body class="lh-today-is-friday">

When the condition is met, you can use CSS to style your page. To change the background of all <h1> tags to red on Friday, you could use the following style:

<style>
    .lh-today-is-friday h1 { background: red; }
</style>

Multiple styles can be combined for complex display options. CSS Body Classes are appended to the existing classes and do not prevent other classes from appearing within the body tag.

Using the CSS Class

Using the CSS class copied from your condition, add it to the class attribute for any HTML element.

<h1 class="logichop-today-is-friday">Happy Friday</h1>

Using Conditional CSS with the WordPress Page Editor

Conditional CSS Example

Using Conditional CSS with the Elegant Themes Page Builder

Conditional CSS Divi Builder

Using the CSS NOT Class

Logic Hop’s Conditional Not logic allows you to display content when a condition is not met.

Conditional Not CSS works exactly the same as Conditional CSS, but with not added to the CSS class.

The example Today is Friday condition, if not met, would appear as the following CSS class:

.logichop-not-today-is-friday { display: block !important; }

The HTML would be written as:

<h1 class="logichop-not-today-is-friday">Sorry it's not Friday.</h1>

Using Conditional Not CSS with the WordPress Page Editor
Conditional CSS Example

Note: Conditional Not CSS is automatically enabled when you enable Conditional CSS.

Page Views <body> CSS

By default, Logic Hop tracks users’ page views and outputs the value as a CSS class in the body of each page such as:

<body class="logichop-views-1">

These CSS classes can be used with your custom CSS to hide and display content for users based on the number of times they have viewed a specific page. This is perfect for landing pages and messaging first-time or returning visitors.

Using Page Views CSS to show content to a first-time visitor

HTML Code:

<div class="first-visit-content">Visible to first-time visitors</div>

CSS Code:

.first-visit-content { display: none; }
body.logichop-views-1 .first-visit { display: block; }

Using Page Views CSS to show content to a repeat visitor

HTML Code:

<div class="repeat-visit-content">Visible to repeat visitors</div>

CSS Code:

.repeat-visit-content { display: none; }
body:not(.logichop-views-1) .repeat-visit-content { display: block; }

Note: Page Views body CSS will not produce reliable results if page caching is enabled. Page Views CSS will not be displayed when Javascript Tracking is enabled.

Disable Conditional CSS

Conditional CSS is enabled by default. When Conditional CSS is loaded, the WordPress core is called and the CSS is generated.

If Conditional CSS is not used, this functionality can be disabled to prevent the additional WordPress core load and provide a minor speed increase.

To disable Conditional CSS, check the Disable Conditional CSS option on the Logic Hop Settings page.