How to extract the variables out from "add_shortcode" function in Wordpress? -
in wordpress (now in template fiile), lets have custom shortcode function, like:
in page:
[myshortcode id='1234']
then, in template file:
function parseuserid_func( $atts ){ //parse $atts here... $userid = 1234; //now userid is, 1234 } add_shortcode( 'myshortcode', 'parseuserid_func' ); //now .. echo value of $userid here? <---------- printout_userdetails( $userid );
as can see, how can processed value of $userid
variable out shortcode function please? (as in last line)
the $userid
not touchable outside.
actually i'm trying like:
- pass
id
page, using[myshortcode id="1234"]
- parse out
id
shortcode's function. (parseuserid_func
above) - when
id
, need pass customfunction printout_userdetails($id){}
function (written in template file) .. continue processing works. - (something like) print out
user details
on page,printout_userdetails()
function.
this why need pass value shortcode
, parse it, pass id
custom function.
any please?
from i'm understanding you're not trying generate output shortcode, save data instead. try using custom fields handle this.
if need output "user details" block within post content (right shortcode written), should merge printout_userdetials
logic actual shortcode handler function (in case parseuserid_func
).
Comments
Post a Comment