function searchstring_wpdb(){
global $wpdb;
$mytables=$wpdb->get_results("SHOW TABLES");
$ss = \'cdn.cloudflare.com\'; //string to search
$used_is = \'\';
foreach ($mytables as $mytable)
{
foreach ($mytable as $table)
{
$existing_columns = $wpdb->get_col("DESC {$table}", 0);
foreach ($existing_columns as $existing_column)
{
$last_link =$wpdb->get_results($wpdb->prepare("SELECT * FROM ".$table." WHERE ".$existing_column." LIKE %s", \'%\'.$ss.\'%\'));
if ($last_link){
foreach ($last_link as $row) {
if (strstr($table,\'postmeta\')){
$used_is .= \', Used in post meta: \' . $row->post_id;
} else if (strstr($table,\'posts\')) {
$used_is .= \', Used in post types: \' . $row->ID;
} else {
$used_is .= \', In Plugin(Table Name): \' . $table . \' And Row ID: \'.$row->post_id.$row->ID.$row->id.\'<br>\';
$check_used = $used_is;
}
}
}
}
}
}
echo $used_is; // return all post id\'s where the string is used
}
add_shortcode(\'show_results\', \'searchstring_wpdb\');
上述代码将在所有wordpress表中找到该字符串,然后获取使用该字符串的posts id。希望这能帮助你。在主题函数中粘贴代码。php文件使用页面上的短代码来获取所有贴子id或表行id中的字符串cd。克鲁夫拉尔。com公司