Advanced box rules

The plugin comes with a basic way of defining rules for where a box should be loaded.

Box targeting options

Using these setting you should be able to do most of your simple targeting based on URL's, posts and pages.

Using advanced logic

However, sometimes you need a little more than that. What if you wanted to show a box only for guest visitors? Or some other custom logic you've set up on your site?

For this, you can use the so-called filter hook boxzilla_load_box.

Example

add_filter( 'boxzilla_load_box', function( $load, $box_id ) {
	return ! is_user_logged_in();
}, 10, 2 );

The above example will apply to all boxes. If you wanted to target a specific box by its ID, you can use the boxzilla_show_box_$box_id hook where $box_id refers to the ID of the box.

Example

add_filter( 'boxzilla_load_box_500', function( $load ) {
	return ! is_user_logged_in();
});

A good place for this code would be in your (child) theme its functions.php file or a plugin of its own.

Was this article helpful? ·