Use AJAX in shortcode

First off, this is very borderline within the scope of WPSE, it at all. Apart from the shortcode to trigger the initial HTML output, this is really just AJAX. Anyhow, that being said, this is how it’s done: The PHP Assuming that the above PHP snippet you supplied is functional, place the following in a … Read more

How to get shortcode’s input values inside a filter?

Using a global variable will work. Here’s a demonstration: function wpse_shortcode_function( $atts ){ // User provided values are stored in $atts. // Default values are passed to shortcode_atts() below. // Merged values are stored in the $a array. $a = shortcode_atts( [ ‘id’ => false, ], $atts ); // Set global variable $value using value … Read more

WordPress plugin shortcode not working

There are a couple of things to check here One: Is your plugin activated. Two: Is your shortcode in your main plugin file. If that code is in another file inside your plugin, did you make sure to include that extra file into your main plugin file Three: Don’t you have any type of error … Read more

shortcodes output before content [duplicate]

Shortcode callbacks have to return, not output. So use the following: function test() { return ‘-TEST-‘; } add_shortcode( ‘testshortcode’, ‘test’ ); More info: http://codex.wordpress.org/Shortcode_API If you have to use echo you can also do it this way(useful if there’s a lot of markup & it’s difficult working with strings)- function test() { ob_start(); echo ‘-TEST-‘; … Read more

Add self-closing shortcode button to TinyMCE in WP 4.6

We start by adding the custom TinyMCE Button: function add_mce_button_custom_em() { // check user permissions if ( !current_user_can( ‘edit_posts’ ) && !current_user_can( ‘edit_pages’ ) ) { return; } // check if WYSIWYG is enabled if ( ‘true’ == get_user_option( ‘rich_editing’ ) ) { add_filter( ‘mce_external_plugins’, ‘add_tinymce_plugin_custom_em’ ); add_filter( ‘mce_buttons’, ‘register_mce_button_custom_em’ ); } } add_action(‘admin_head’, ‘add_mce_button_custom_em’); … Read more

Custom shortcode being executed when saving page in wp-admin

Shortcodes must return, not echo or print their output. As the Codex entry for add_shortcode() explains: Note that the function called by the shortcode should never produce output of any kind. Shortcode functions should return the text that is to be used to replace the shortcode. Producing the output directly will lead to unexpected results. … Read more

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş