Delete posts with word count less than x number of words

function delete_posts() { $lastposts = get_posts(array(‘numberposts’ => -1)); if ( $lastposts ) { foreach ( $lastposts as $post ) : setup_postdata( $post ); ?> <?php $content = get_the_content(); if (str_word_count($content) < 100) { wp_trash_post($post->ID); } ?> <?php endforeach; wp_reset_postdata(); }}add_action( ‘init’, ‘delete_posts’ );

MySQL update text field with ‘

Apparently someplace in the wp_list_table, or maybe someplace else, the escape character \ was inserted before any ‘ . I was able to solve this by adding this line of code just before the $wpdb->update statement. $item[‘RecordedSubdivision’] = str_replace(“\'”, “‘”,$item[‘RecordedSubdivision’]);

Custom query_posts() parameter

If you have your data in separate table adding support for it in query is somewhat messy. Basically you will need to filter posts_where and posts_join to modify raw SQL query so that your custom table is joined and checked against your custom values. As per [faster :)] anu’s suggestion it would make sense to … Read more

Custom Search, MySql Query Gone Wrong?

This doesn’t seem especially complex, but does seem bulky and prone to errors. As I answered couple of times on similar issues – if this isn’t time critical then wait for WP 3.1 because it will have major improvements for querying by custom fields. See Advanced Metadata Queries for brief writeup on upcoming improvements. For … Read more