Database connection close

You don’t have to worry about closing connection to you DB because it will be automatically closed when a request will be processed by your server. But if you have to close it, then you can do something like this: @mysql_close( $wpdb->dbh ); Pay attention that it could lead to unexpected results because other plugins … Read more

What’s wrong with my $wpdb query?

When you use $wpdb->prepare the placeholder %s is replaced with something between quotes, so, your query becomes: “SELECT * FROM ‘wp_users’ WHERE ID = 1” but table names in SQL queries must not be wrapped in quotes. So, the right way is: $sql = $wpdb->prepare( “SELECT * FROM {$wpdb->users} WHERE ID = %d”, 1 ); … Read more

Link to handle $_GET request

If this is in the admin, use the action parameter: <a href=”https://wordpress.stackexchange.com/questions/159391/<?php echo esc_url( admin_url(“?action=delete_ticket&ticket_id=$ticket->ID” ) ?>”>Delete item</a> …and then hook appropriately: function wpse_159391_delete_ticket() { if ( isset( $_GET[‘ticket_id’] ) ) { // delete it! } } add_action( ‘admin_action_delete_ticket’, ‘wpse_159391_delete_ticket’ ); For the front-end, you can just append your parameters to the current url and … Read more