Get ID of the page where shortcode is included
Get ID of the page where shortcode is included
Get ID of the page where shortcode is included
The other shortcode plugin probably includes this code: add_filter( ‘widget_text’, ‘do_shortcode’ ); If you add this to your theme’s functions.php, the shortcodes might render?
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.
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
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
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
The issue is that each time a shortcode is processed, you’re overwriting the previous value with the new value, so you’ll always only get the data for the last instance of your shortcode. The simplest way to work within what you’ve already got is to put the data into an array. global $pslider; // generate … Read more
If I understand this correctly it looks like echo ‘<?php do_shortcode(“[inline_upload]”); ?>’; should be echo do_shortcode(“[inline_upload]”); So that it actually runs the short code instead of echoing the code.
You can try to add this filter <?php /** * Plugin Name: Shortcodes support for the Custom Fields Widget plugin * */ add_filter( ‘custom_field_value’, ‘do_shortcode’ ); as a plugin. This should hopefully make your shortcodes work. Here you can read more about the WordPress function do_shortcode().
I checked your solution (copy and paste) and it is working fine in WordPress 3.7.1 Maybe check your post again. Can you provide a link to your site? (can not comment yet, thats why I answer)