Query Attributes optional argument – WordPress Development Stack Exchange
Question
I am using this code which currently the user calls as: [myimg no="1"] , [myimg no="2"]
etc..
function myimg_shortcode($atts){
$atts = shortcode_atts( array('no' => 1,), $atts );
$no = is_numeric( $atts['no'] ) ? (int) $atts['no'] : 1;
$no -=1 ;
}
add_shortcode('myimg', 'myimg_shortcode');
I am looking to add another optional string attribute so that for example the user will have the option to specify [myimg no="3" id="test"]
where test should become the value of the string variable $id
in the code. The no
attribute is always required, whereas id
should be optional.
0
2 years
2021-03-22T10:39:39-05:00
2021-03-22T10:39:39-05:00 0 Answers
0 views
0
Leave an answer