How to write: $wpdb->update having WHERE NOT value pair in the array

The $wpdb class properties

You can use all the default WordPress tables like this:

  • $GLOBALS['wpdb']->postmeta

so no need to use prefix, etc.

meta_query

As you can see from the Custom field parameter documentation, there’s nothing like the <> (or in other words: “not equal to”) operator. The equivalent operator in WP should be != (human words: “not is”) or NOT LIKE.

So simply do something along the following lines:

$query = new WP_Query( array(
    'meta_query' => array(
        array(
            'key'     => '_wti_like_count',
            'value'   => '0',
            'compare' => 'NOT LIKE',
            # 'type'    => 'numeric'
        )
    )
) );

This would query all your posts with this meta value. What makes me wonder is why you got a string as an integer. I wouldn’t do that, especially not if I use a counter. See what I commented out: The type, which would allow you – later on – much more specific queries.

Update the meta entries

Then simply loop through them and update the values.

if ( $query->have_posts() )
{
    while ( $query->have_posts() )
    {
        $query->the_post();
        # Do debugging, logging or sleep() here to avoid timeouts
        update_post_meta( '_wti_like_count', '0', true );

        # I still believe it should be an INTeger
        update_post_meta( '_wti_like_count', 0, true );
    }
}