Does worpress use Elementor page editor to php and mysql database syntax on the page?

Viewed 39

Do I want to use the code area of the Elementor page editor to type the following code on the page?

The code is as follows:

$db_host="localhost";<br>
$db_username="root";<br>
$db_password="";<br>

$db_link=@mysqli_connect($db_host,$db_username,$db_password);<br>
if(!$db_link){
    die("資料庫連結失敗!");
}

$seldb=@mysqli_select_db($db_link,"studentscore");          
if(!$seldb){
    die("資料庫選擇失敗!");
}

mysqli_query($db_link,"SET NAMES 'utf8'");      
1 Answers

No, you can't, code block in Elemntor accepts only HTML code or JS or CSS, you can create a separate file with this code and register a shortcode and then do a shortcode in the Elementor block, as I remember it has a special box for shortcodes, and it actually should read shortcodes anywhere on the WordPress page

For example, you create the file in your theme folder called "short-code.php"

 function your_function(){
Whatever is your function doing;
}

and then making a shortcode like this under your function code

add_shortcode('short-code-name', 'your_function');

you can also make some parameters in your short-code

then to display it on your page simply add this anywhere you want to do this shortcode

[short-code-name]

Hope that will lead you to the correct answer

Related