Hi,
i stumbled upon this code: https://kriesi.at/support/topic/custom-avia-shortcodes/
While it works for a child theme, it seems not to work for a plugin:
$plugins_url = plugin_dir_url( __FILE__ );
add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
function avia_include_shortcode_template($paths)
{
array_unshift($paths, $plugins_url.'shortcodes/');
return $paths;
}
Pathes are accordingly changed for plugin – but i cannot see them in the layout builder.
I also tried the setup after the theme – doesnt work either, any help appreciated
$plugins_url = plugin_dir_url( __FILE__ );
add_action( 'after_setup_theme', 'loadPlugin' );
function loadPlugin() {
add_filter('avia_load_shortcodes', 'avia_include_shortcode_template', 15, 1);
}
function avia_include_shortcode_template($paths)
{
array_unshift($paths, $plugins_url.'shortcodes/');
return $paths;
}
Hi,
I think your code won’t work because $plugins_url is not defined as global var. You can try this code instead:
function avia_include_shortcode_template($paths)
{
global $plugins_url;
array_unshift($paths, $plugins_url.'shortcodes/');
return $paths;
}
or you define the $plugins_url var inside the function like:
function avia_include_shortcode_template($paths)
{
$plugins_url = plugin_dir_url( __FILE__ );
array_unshift($paths, $plugins_url.'shortcodes/');
return $paths;
}
Best regards,
Dude