Home / Admin / Add Custom Dynamic Variables
Duplicate Snippet

Embed Snippet on Your Site

Add Custom Dynamic Variables

The Total theme allows you to use "Dynamic Variables" in various element text fields such as {{post_title}}, {{current_url}}, {{post_author}}...etc. If you wish to add your own custom dynamic variables it's possible using the "totaltheme/replace_vars/vars" filter.

Code Preview
php
<?php
add_filter( 'totaltheme/replace_vars/vars', function( $vars ) {
    // Add a new {{my_custom_var}} custom variable.
    $vars['my_custom_var'] = 'My variable value';
    return $vars;
} );

Comments

Add a Comment