It looks like your code works as written.
Alternatively, you can generate an alphanumeric string using uniqid()
…
<a href="http://meet.jit.si/<?php echo uniqid()?>" target="_blank"> click here </a>
EDIT: Modified code based on additional information.
This should create a shortcode that allows you to easily add a button to a unique meeting link by adding [rand_jitsi_btn]
to a post/page:
// hook our shortcode creation to `init` so that WordPress has time to initialize properly
add_action( 'init', 'add_custom_shortcode' );
function add_custom_shortcode() {
add_shortcode( 'rand_jitsi_btn', 'create_rand_jitsi_btn' );
}
// Code to create the button
function create_rand_jitsi_btn() {
return '<a href="http://meet.jit.si/' . uniqid() . '" target="_blank"> Launch Meeting </a>';
}
I haven’t tested this code, but it should work if you place it in your child theme’s functions.php
file.
Note: You can use something like random_int()
instead of uniqid()
if you need numeric randoms.