Support » Plugin: Manual Related Posts » $wpdb->options

  • In inc/ you have this line near the bottom:

    $wpdb->query( "DELETE from $wpdb->options WHERE option_name LIKE '%bawmrp_{$post_ID}%'" );

    This actually doesn’t work as expected on my multisite installation. If I remember rightly (I found this error months ago), the problem was that when you save the related posts, you do it via set_transient(). That creates an entry in the sub-site’s options table (i.e. wp_2_options), which is exactly what we want. But when you delete it, you use $wpdb->options, which doesn’t take multisite into consideration, so you actually delete from the generic wp_options table, rather than the individual sub-site table. This caused the transients to never get deleted.

    I was able to fix the problem by replacing it with this instead:

    $wpdb->query( "DELETE from " . $wpdb->get_blog_prefix() . "options WHERE option_name LIKE '%bawmrp_{$post_ID}%'" );

    get_blog_prefix() will get the database prefix, taking multisite into consideration. Then append “options” to it.

    I’d appreciate it if you could adjust this so I don’t have to make the patch on my own after every update. 🙂

  • The topic ‘$wpdb->options’ is closed to new replies.