$wpdb->insert is changing a value

Great advice Rarst! The output of $wpdb->queries was exactly what it should be: “INSERT INTO `wp_featured_releases` (`fr_band`,`fr_album`,`fr_album_description`,`fr_image_id`,`fr_shop_url`,`fr_modified`) VALUES (”,”,”,’504′,”,’2011-01-14 10:49:58pm’)” 504 is the correct id for the image, but the value in the table is still 127. My latest thought is that my mysql skills have failed me. Images with an ID below 127 work … Read more

Plugin to Consume a Web Service

The link you’ve giving is for the function add_rewrite_tag() not WP_Rewrite::add_rewrite_tag()Codex. The later documentation is a bit misleading because it links the other global function (which has two arguments) as if it was the same. But the function you’re referring to has three arguments. I updated the codex a bit to make this more clear.

wp_query (and post_id) is empty in admin_init

In the admin, there is not such thing as the current WP_Query, because most of the pages on the admin are not linked to any post, so the pages that have any relation to a post you should grab the ID from the $_GET like that: add_action(‘admin_init’,’do_optional_featured_article’); function do_optional_featured_article() { if( isset($_GET[‘post’]) ) { $post_id … Read more

What is the difference between strip_tags and wp_filter_nohtml_kses?

Technical difference is kinda obvious. PHP one is single function, using logic in PHP code. WP one is one of family of functions, based on third party KSES library. Is there practical difference between these two specific functions? I think the important point is that strip_tags() was made for utility, while KSES was made for … Read more

How to modify post content before writing to database?

You generally use add_filter before displaying information. For your case you can use add_action(‘publish_post’, ‘your_function’) and then you intercept $_POST values. The content of the WYSIWYG editor is available through $_POST[‘content’]. The hook is of type publish_{post_type} btw. You should change accordingly. Example: function wpse_89292_save_my_post() { print_r( $_POST[‘content’] ); # will display contents of the … Read more