简体   繁体   中英

How do I add a PHP (or similar) variable into HTML in a Wordpress page?

I have a dropdown FAQ page on my website that can be edited with Elementor, but I'm knowledgeable of accessing files in my child theme etc, though have some confusion as to how to actually apply PHP (or similar) variables into my standard HTML section in Elementor.

If there are any video recommendations (I've looked, but I'm not exactly sure what it is I am trying to do here as my server-side knowledge is near zero) I'd greatly appreciate a link. Also, please feel free to correct me if I'm missing something spectacularly here (such as this being in the incorrect coding language altogether).

<p class="section heading">
  My first section goes here.
</p>

Instead of first I would like the ability to add a variable that I can change only once (this heading will be used on many pages)

<p class="section heading">
  My <?php $myVariable ?> section goes here.
</p>

You have two options.

1. Use echo

Example: <?php echo $variable; ?> <?php echo $variable; ?>

2. Use short version If you are using php version < 7.4 (this function removed in php8 > source )

In this case the php function short_open_tag should be turned on in php.ini file.

Example: <?=$variable?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM