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:

  1. pass id page, using [myshortcode id="1234"]
  2. parse out id shortcode's function. (parseuserid_func above)
  3. when id, need pass custom function printout_userdetails($id){} function (written in template file) .. continue processing works.
  4. (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

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -