There may be times when you don't want entire rows or modules to show up when a field connection is empty.
If you don't need to hide entire rows or modules, you can use conditional shortcodes instead of PHP code to display field connections only when they return content.
You can use the following code to hide rows or modules that have empty field connections. Add it to your child theme's functions.php file.
This code is just a starting point and will not work in every situation. Use your knowledge of PHP to extend this code, using the
$node variable to choose which rows, columns or modules are hidden based on a number of circumstances such as
The examples below are common use cases on how to hide rows, columns and modules.
The example below removes a row if row has a class of
The example below removes a column if column has a class of
The example below removes a module if module has a class of
Hide row on a specific page if row has class of
my-target-row and page id is
123. You can refactor this code to work on other WordPress pages such as archives or the front page. To do this you will need to use WordPress conditionals.
You can also replace the row with a column or module by changing the
if ( 'column' === $node->type )for column
if ( 'module' === $node->type )for module.