Shortcoding with Divs

This should do the trick: http://codex.wordpress.org/Shortcode_API#Output Copying verbatim from the documentation: function myShortCode() { ob_start(); ?> <HTML> <here> … <?PHP return ob_get_clean(); } Basically what happens is that all your HTML will not be output, but rather stored in an “output buffer”, and returned by the function.

Can I use widgets & shortcode if I need to return an array?

I think that your proposed solution, or plan of attack, is far more complicated than it needs to be. You can use a static variable to manage this. Proof of concept: function shortcode_with_static_data($atts,$content) { static $ids; $ids[] = time(); var_dump($ids); // you should return a string not dump data in a real shortcode } add_shortcode(‘scwsc’,’shortcode_with_static_data’); … Read more

Initialize add_action() for every copy of a specific shortcode

You can pass values by adding your own filter. Proof of concept: add_filter( ‘my_filter’, function() { return array(1,2,3); } ); function print_partners_scripts() { $args = apply_filters(‘my_filter’,null); var_dump($args); } add_action( ‘wp_footer’, ‘print_partners_scripts’ ); Where you to register and enqueue your script instead of echoing it directly to the page, you could use wp_localize-script to pass information … Read more

Identifying a Page Containing Shortcode at `init`

I’ve found an answer, although messy. /* // Plugin information goes here */ $GLOBALS[‘example_class’] = new example_class; class example_class { var $public_loaded = false, $content=””; public function admin_init() { add_menu_page( // … ); } // End of admin_init function public function get_random( ) { // … } } // End of example class add_action(‘init’, function() … Read more