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

SQL trigger failes with post_content

I’ve written a filter for you. It will filter the character before the post get saved in the database and it’s using the WordPress way. If you use this I think you’re not gonna be needed the trigger. Here it is- add_filter( ‘wp_insert_post_data’ , ‘the_dramatist_filter_content_before_insert’ , ’99’, 2 ); function the_dramatist_filter_content_before_insert( $data , $postarr ) … 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

Track write actions to the database

Seems like there’s a plugin out there that does quite this! It’s VersionPress! In this blog post is explained what they used to track all the complicated changes. Instead of using the ‘query’ filter they use the option to create a db.php file in the wp-contents directory to extend $wpdb like explained in this post: … Read more

My plugin can’t see my files

Answering my own question just in case someone comes across it looking for an answer. Managed to figure it out! We have to get the URL as follows, we can’t just reference it like we normally would on a server plugins_url( ‘products.csv’, __FILE__ ); The above code returns the information we need, rather than just … Read more