Pass a variable from a shortcode
-
Long story short:
I need to use an attribute from a shortcode outside of the shortcode function. I am very new at .php and I am not sure how to proceed.The long story:
I have a database (separate from the WP database) that I store information in to be retrieved by posts/pages. Currently, I am using this database to generate html that I copy/paste into my WP pages.I have written a series of .php pages that retrieves the information I need in my posts/pages. Now I just need to have them display in WP. I figured the easiest way was to use a shortcode to call the page to load. I am using the Shortcode Exec PHP plugin with the following code:
extract(shortcode_atts(array( 'type' => 'list', 'id' => 'alpha', ), $atts)); require_once( '(link to the page to be loaded)' );I need to pass
$typeand$idto the .php page called from the function to determine what path/series of .php files are executed in what order.Please let me know if I am not being descriptive enough in my explanation. I have been trying to get this done for about a week now and am at my wits end.
Thank you in advance for your time and help. Have a great day!
The topic ‘Pass a variable from a shortcode’ is closed to new replies.