You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: search-posts-media-library.sh
+2-8Lines changed: 2 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -27,12 +27,6 @@ for site_id in $all_site_ids; do
27
27
continue;
28
28
fi
29
29
30
-
echo>>$output_file;
31
-
echo"Results for Site ID ${site_id}">>$output_file;
32
-
33
-
# Search for multi term phrases. Cases sensitive.
34
-
wp_skip_all db query --skip-column-names "SELECT ${fields} FROM wp_${site_id}_posts WHERE post_type = 'attachment' AND post_REGEXP '${search_regex}';">>$output_file;
35
-
36
30
# The SQL query for searching the media library of a network site.
37
31
sql_query="SELECT
38
32
$site_id as site_id,
@@ -50,10 +44,10 @@ for site_id in $all_site_ids; do
50
44
51
45
# Check if a search string was provided.
52
46
if [ -n"$search_regex" ];then
53
-
QUERY="$QUERY AND p.post_title REGEXP '${search_regex}'"
47
+
sql_query="$sql_query AND p.post_title REGEXP '${search_regex}'"
54
48
fi
55
49
56
-
wp_skip_all db query --skip-column-names "SELECT ${fields} FROM wp_${site_id}_posts WHERE post_type = 'attachment' AND post_REGEXP '${search_regex}';" tee -a $output_file;
50
+
wp_skip_all db query --skip-column-names "$sql_query"| tee -a $output_file;
0 commit comments