Adding variable in WordPress shortcode

Rather than passing the variable contents in to the shortcode, you would probably be better to pass in the URL parameter you are setting, i.e. [post color=”color” width=”980″ heigh=”610″]. Because your shortcode will execute during load in PHP, you can then tell your shortcode function to store the value of $_GET[‘color’] to later use in … Read more

Why it doesn’t create a custom post type after form submitting

wp_enqueue_scripts action is not meant to add PHP code to your page. It is used to add JS scripts. https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/ wp_enqueue_scripts is the proper hook to use when enqueuing scripts and styles that are meant to appear on the front end. Despite the name, it is used for enqueuing both scripts and styles. If you … Read more

Submitting form to PHP

You’re trying to combine isset with a value comparison, and that’s not how it works. You should rewrite this: if(isset($_POST[‘Client_Type_Edit’]) == ‘Individual’) to this: if ( isset( $_POST[‘Client_Type_Edit’] ) && ‘Individual’ === $_POST[‘Client_Type_Edit’] ) This is checking to make sure that $_POST[‘Client_Type_Edit’] is set AND the value is equal to “Individual”. Now repeat that for … Read more

shortcodes, custom php and their errors

The answer is: function reservations_yesterday() { global $wpdb; $results = $wpdb->get_var (“SELECT SUM(`mattiscool`), booking_date FROM `wp_cbxrbooking_log_manager` WHERE `booking_date` = CURDATE() -1”); return $results; } add_shortcode(‘name’, ‘reservations_yesterday’);

wpdb->query returns different value to phpMyAdmin

You need to read the manual for the functions you’re using as all the information for how to debug is contained there. $wpdb-query() description is very clear. The return value is: (int|bool) Boolean true for CREATE, ALTER, TRUNCATE and DROP queries. Number of rows affected/selected for all other queries. Boolean false on error. As mentioned … Read more