First thing, wp_head
action hook does not accept any argument at all, so am not sure whether the $url
variable will be passed.
To run the short code properly, you have to call do_shortcode():
add_action( 'wp_head', 'refresh_page' ); function refresh_page() { echo do_shortcode( "[refresh url="http://stackoverflow.com"]" ); } add_shortcode( 'refresh', 'refresh_shortcode' ); function refresh_shortcode( $atts ) { $atts = shortcode_atts( array( 'url' => '', ), $atts, 'refresh' ); $url = esc_url_raw( $atts['url'] ); return '<meta http-equiv="refresh" content="' . $url . '">'; }
Related Posts:
- How to add inline css/js inside a shortcode
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Shortcode display outside the div
- add action wp_head not working
- How to add a shortcode button to the TinyMCE editor?
- Where is the best place to use add_filter
- Custom media upload content for inserting custom post shortcode
- Checking if an attribute exists in a shortcode
- When can you get current page ID and initialize hooks right after?
- enqueue script only if it is not already enqueue
- Autogenerate wordpress shortcodes using array?
- Using the ‘draft_to_publish’ hook (post status transition)
- How to load different css file for different pages
- How can I limit functionality in one version of a plugin?
- How To Ignore a Filter On Applying Filter the Content In a Function
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- append stylesheet via shortcode
- Pass $this to function nested in another public function of the same class
- shortcode doesn’t work
- Can a plugin add to header/footer/body content?
- Is it possible to add an action to the currently running action?
- Action on post publish
- How to call bind function in wordpress actions or hooks
- How to prevent action in ajax request, when in admin side?
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- template_redirect not being called when using ajax
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- ‘wp_login’ action hook not working with wp-login.php file
- Demystifying and understanding shortcode nomenclature
- Any Short code Availble for Get Post List With Thumbnail Plugin?
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- Any hook for pre-plugin-update -either bulk or single plugin update
- Input with spaces in Shortcode attributes overwritten by defaults
- wordpress plugin is not activating from widget
- Allow users of my plugin to define their own shortcode rather than use mine?
- When to load auto-login code?
- How to get all of the activate_plugin action parameters?
- Making a Template for a CPT created by a plugin
- How to check current user before all actions and filters?
- creating html reusable blocks via shortcodes
- Single API call exposed via shortcode with params
- Get Time Taken By Each Action Hook in WordPress
- Are functions in main plugin file called before function bound to register_activation_hook runs?
- Custom plugin init action causing general slowness
- Creating shortcodes in plugin
- How to create a custom shortcode based on the layout?
- wp_footer hook only working on homepage not in other pages
- Create shortcode to echo javascript
- Redirect to another page using contact form 7? [closed]
- What is @Action in WordPress?
- Add action to fire when a published post is updated
- Namespaced shortcode?
- How to pass variables to a function argument using add_action [duplicate]
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Submit Form data to another page via Ajax (WordPress Way)
- Why am I unable to load scripts in head in plugin?
- Does using `add_action( ‘init’…` cause performance issues?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- Hook for page Request?
- IF condition based on wp_remote_get output
- Shortcode Attributes to Return different $_POST
- wp_enqueue_style on template_redirect level?
- How to use template inside plugin shortcode with variables for big HTML code
- strange shortcode error: does shortcodes requires any dependency?
- How to rewrite URL and get the values?
- Custom CSS not being added by plugin
- How to use add_action for multiple instances of the same class
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- I cannot include a file in my plugin settings page
- Thumbnail image doesn’t show up in Shortcode output
- list of custom post by custom field in frontend
- Shortcode do not return the right data in post
- How to call function in WordPress on button click?
- Why do actions with class and public method don’t fire __construct()
- The function called on the wp head hook becomes null
- Hide content for specific users with id
- i create functions.php in plugin files but add_action (‘wp_head’, ‘function_name’) don’t work
- Why is my shortcode not working?
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Get post content inside plugin class method
- Remove action added in plugin class from theme
- WP Plugin CSS not being applied to page
- echo plugin results on pages
- Modify Plugin PHP Class in Child Theme – Correct Method
- Front End Page Not Loading Header Footer
- Shortcode in a blog post, footer and related products stop working
- shortcode which is introduced into entry the blog, and appears in side bar
- Plugin Hook: Get posts
- Why function hooked using object are executing at all time?
- Shortcode registered from a plugin not recognized
- Is it possible to cancel a post status transition?
- How wordpress plugin hooks works? [duplicate]
- Any way to hook into WP after a page displays?
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- Display file contents within Plugin
- How to add a box note in wordpress plugin page ? top header side.
- How can I pass value to function in add_menu_page?