To set a variable, such as an url, you can use the following steps:
- add to your wp-config a code with something like
require_once ABSPATH . 'wp-settings.php';
/** variabili */
define('GLOSSARIO_URL', 'yourwebsite/glossario.php');
- add to functions.php (in your wp theme root) something like
define('GLOSSARIO_URL', 'yourwebsite/glossario.php');
function glossario_link($atts) {
$atts = shortcode_atts([
'id' => '',
'testo' => ''
], $atts);
$url = GLOSSARIO_URL . '#' . $atts['id'];
return '<a href="' . esc_url($url) . '">' . esc_html($atts['testo']) . '</a>';
}
add_shortcode('glossario', 'glossario_link');
- in wp editor you will be able to call that code inserting a text like this:
[glossario id="universalismo" testo="universalisticamente"]
where the content of testo="" is what will appears in your wp page (while in the editor you will see that code)