I’ve added this capability in version 4.1.0!
Method 1: use your theme
If you’re using a custom or child theme, you can certainly add your custom code there and it won’t get overwritten when this plugin is updated.
Method 2: use a plugin
Alternatively, if you’re not super code-savvy (more for other people who land on this thread that might not be), you can check out this Code Snippets plugin. I’ve never used it but it seems to be highly rated and recommended.
Method 3: create the dtx.php file
In version 4.1.0, I introduced a feature that looks for a dtx.php
file in three (3) locations:
- the
wp-content
directory (e.g. file path C:\path\to\website\wp-content/dtx.php
or URL example.com/wp-content/dtx.php
)
- the directory of your currently active theme (e.g. file path
C:\path\to\website\wp-content/themes/my-theme/dtx.php
or URL example.com/wp-content/themes/my-theme/dtx.php
)
- the parent directory of your current active theme (e.g. file path
C:\path\to\website\wp-content/themes/parent-theme/dtx.php
or URL example.com/wp-content/themes/parent-theme/dtx.php
)
And calls them using include_once
should they exist. Does nothing if they don’t. So you can create that file, modify it however you see fit, and upload it via FTP to be executed.
To speed up your custom shortcode creation, you’re welcome to call any of the functions defined in DTX’s shortcodes.php and utilities.php directly such as wpcf7dtx_post
, wpcf7dtx_get_post_var
, or wpcf7dtx_format_atts
, that way you don’t have to always define functions for getting variables from things, you can just call the appropriate function and get right to it, outputting what you need your custom shortcode to output.