How do I insert content of various MySQL fields in post?

I also would vote for creating a short code. The shortcode code could pull data from a database/table, and ‘build’ the text you want with values from the table. Lots of googles on how to build shortcodes – check those out, vs me putting some sample code here. You would put the shortcode function in … Read more

Filter on the day of the week from timestamp

This answer may help someone who really wants to customize their filters. With PhpStorm and breakpoints I could walk through how the meta_query is constructed before posts are fetched. There are no hook points in the flow that let developers accomplish this; I’ve used a SQL-injection trick to achieve the filter. // Do advanced SQL … Read more

Advanced WordPress SQL Query

In WP, you rarely need to “write SQL queries”, unless you work with custom tables, instead use its API… WP_User_Query will join for you all meta data attached to each user and return to you plain user objects, so why not use it instead? Also, see get_user_meta()…

get/show Last ID

to have the ID, you can try this hook e.g. add_action(“save_post”, function ($post_ID, $post, $update) { if ( !$update && class_exists(“Flamingo_Inbound_Message”) && (Flamingo_Inbound_Message::post_type === $post->post_type) ) { // here $post_ID is the ID of the new created inbound message } }, 10, 3);

How to do a MySql query in WordPress?

You can write your own MySQL queries by getting the global $wpdb variable and preparing a SQL statement and then getting the results. global $wpdb; $prepared_query = $wpdb->prepare( ‘SELECT * FROM [your_table] WHERE LAST_INSERT_ID();’ ); $results = $wpdb->get_results( $prepared_query ); Please, be very careful when using this, if you do it incorrectly, it could be … Read more