config file defined value used in a shortcoe
-
say I define an environment variable in wp-config
define(‘PHOTOBASE_URL’, ‘https://somedomain.com/photos’);.how can I access that variable in a html shortcode (say using shortcoder)
The idea is this case is to use it in an img tag so that the user only enters their photo filename as a parameter and the shortcode creates the full URL.
I suppose I could access it via php in the short code like this
<?php $url = PHOTOBASE_URL ?>
then in some html
<img src=”<?= $url ?>%%filename%%” >but is does the shortcode api have a way to identify/parse these in the html maybe using some special delimiters?
I’ve done this in a static site generator, Hugo, that supports shortcodes but there is an easy syntax for accessing site object variables in the hmtl.
- The topic ‘config file defined value used in a shortcoe’ is closed to new replies.