How to pass the parameter in is the add_shortcode?

I do not understand how to pass a parameter to a function in true_url_external
is the add_shortcode( 'trueurl', 'true_url_external' );

Because here you specify only the function name, and I need to pass external parameters there.

don't I need to pass an external parameter from another function
while ($row = mysqli_fetch_row($result)) {
 $pricearray = json_decode($row[17], true);
 $price = $pricearray['custprice'];
 is the add_shortcode('insert_room_price_'.$row[0], 'funcshort');
 }

$price need to pass
March 23rd 20 at 18:56
2 answers
March 23rd 20 at 18:58
Solution
Because here you specify only the function name, and I need to pass external parameters there.

Here you can specify not only the name of the function but pass any callable.
For example, here you can put an anonymous function that collects the necessary parameters and will call your named:
while ($row = mysqli_fetch_row($result)) {
 $pricearray = json_decode($row[17], true);
 $price = $pricearray['custprice'];
 is the add_shortcode('insert_room_price_'.$row[0], function() use ($price) { 
 return funcshort($price);
});
}
thank you - vito commented on March 23rd 20 at 19:01
March 23rd 20 at 19:00
is the add_shortcode( 'name', 'func' );
function func( $atts ){
 $params = shortcode_atts( array(
 'param1' => null,
 'param2' => null
 ), $atts );

 return 1;
}

// pass the parameters
[name param1=1 param2=2]
don't I need to pass an external parameter from another function
while ($row = mysqli_fetch_row($result)) {
 $pricearray = json_decode($row[17], true);
 $price = $pricearray['custprice'];
 is the add_shortcode('insert_room_price_'.$row[0], 'funcshort');
 }

$price needs to be said, that is the shortcode you want to display $price, but it is not necessary to specify, as it is taken from a variable, and make sense to specify this parameter in the shortcode if it is easier to manually register =) - vito commented on March 23rd 20 at 19:03
@vito, then it is not the parameters of the shortcode - adele commented on March 23rd 20 at 19:06
@adele, Yes, but I do not understand why this shortcode if you want to handle occasionally, even impossible to automate in a loop - vito commented on March 23rd 20 at 19:09
@vito, you are confusing salt with hot. - adele commented on March 23rd 20 at 19:12

Find more questions by tags WordPress