Why does WP not like my container?

I think it’s safe to say that wpautop() is a basket case without hurting anyone’s feelings, but I wouldn’t remove & add it at a different priority as that just makes things worse, as demonstrated (although what you posted is the browser trying to make sense of broken html, rather than the actual output, which … Read more

Shortcode to Gutenberg-block: additional text on front-end and conditional display

Although a little different than I had initially anticipated, I have found/created a solution to my two problems. Conditionals I have opted to move non-required input to the sidebar, using the InspectorControls-element. Reason for this is that I realised that it would be impossible to hide a field (in the editor-part of the screen) that … Read more

Ajax not returning anything on form submit

Shortcodes are too late to add ajax actions. Additionally, that actions would be added only if shortcode is executed, which is very unlikely to happen on a ajax request. The quickest way to make your code work is to move the add_action outside addimage() function. add_action( ‘wp_ajax_wp_up’, ‘wp_up’ ); add_action( ‘wp_ajax_nopriv_wp_up’, ‘wp_up’); function wp_up() { … Read more

Get shortcode attributes outside shortcode function

You can pass an array to your script with wp_localize_script($handle, $object_name, $l10n). function test_function( $atts ) { $data = shortcode_atts( array ( ‘arrows’ => TRUE ), $atts ); wp_enqueue_script( ‘your_script_name’ ); wp_localize_script( ‘your_script_name’, ‘yourScriptObject’, $data ); return ‘a string’; } In your (external) script you can access the shortcode data now with … var arrows … Read more

Getting attribute value from shortcode

I read your question differently than @eric-holmes. It sounds to me like your shortcode needs to function normally under most circumstances but that you are extracting information in special circumstances. Shortcode regex is tricky. Let WordPress do it for you. $pattern = get_shortcode_regex(); preg_match_all(“/$pattern/”,$wp_content,$matches); Your attributes for any shortcodes present in $wp_content should now be … Read more

Shortcode not working inside html input

As above, https://wordpress.stackexchange.com/a/195673/22728 solved it: add_filter( ‘wp_kses_allowed_html’, function ( $allowedposttags, $context ) { if ( $context == ‘post’ ) { $allowedposttags[‘input’][‘value’] = 1; } return $allowedposttags; }, 10, 2 );

How to create a shortcode to display a category description?

Try this. Add the code below to your functions.php file – add_shortcode(‘cat_description’, ‘my_cat_description_shortcode’); function my_cat_description_shortcode($atts){ $a = shortcode_atts( array( ‘id’ => 0, ), $atts ); return category_description($a[‘id’]); } Should you wish to call the shortcode from a template (unnecessary really unless you add more to the shortcode) you can use this code – <?php echo … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)