CONCAT_WS in custom sql query

‘CONCAT_WS(‘,’, wp_postmeta.meta_key, wp_postmeta.meta_value)’ was the name of the column. Everything is working as it should. To change the name of the column, add AS name after the CONCAT_WS statement, like this: ‘CONCAT_WS(‘,’, wp_postmeta.meta_key, wp_postmeta.meta_value)’ AS name (I didn’t test this specifically). Now the new column will be called name.

Generating an HTML table from an array based on dynamic key values

Here is the tested solution- // Your sample array $sample_array = array( 0 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘John’ ), 1 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘James’ ), 2 => array( ‘meta_key’ => ‘cpf_first_name’, ‘meta_value’ => ‘Jane’ ), 3 => array( ‘meta_key’ => ‘cpf_gender’, ‘meta_value’ => ‘Male’ ), 4 => array( … Read more

Adding featured for post using database

First of all, never ever use Plain SQL query to WordPress, because it’s too dangerous. Try $wpdb class, if you need to. BTW, adding posts, post description, assigning featured image, etc. there are wrapper functions designated for these particular tasks, like: wp_insert_post() set_post_thumbnail() – for assigning featured images Always, try to consult Codex or Developer … Read more