You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何给WooCommerce产品追加‘course’,同时排除含‘bundle’的记录?

How to Append 'course' to WooCommerce Products (Excluding Those with 'bundle')

Absolutely feasible—this is a common use case that can be handled with a targeted UPDATE query tailored to WooCommerce's database structure. WooCommerce stores product titles in the wp_posts table (your table prefix might differ, e.g., wp_ is the default) where post_type = 'product'. Here's the step-by-step solution:

The Core SQL Query

UPDATE wp_posts
SET post_title = CONCAT(post_title, ' course')
WHERE post_type = 'product'
  AND post_title NOT LIKE '%bundle%';

Breakdown of the Query:

  • UPDATE wp_posts: Targets the posts table where WooCommerce products are stored.
  • SET post_title = CONCAT(post_title, ' course'): Appends the string ' course' (note the leading space to avoid merging words awkwardly) to the existing product title.
  • WHERE post_type = 'product': Ensures we only modify actual products, not pages, posts, or other post types.
  • AND post_title NOT LIKE '%bundle%': Excludes any product whose title contains the word 'bundle' (the % wildcards match any characters before or after 'bundle').

Critical Pre & Post Steps:

  • Backup First: Always back up your database before running UPDATE queries—once executed, changes can't be undone easily.
  • Check Table Prefix: If your WordPress installation uses a custom table prefix (not wp_), replace wp_posts with your actual prefix (e.g., my_store_posts).
  • Case Sensitivity: By default, LIKE in MySQL is case-insensitive on most collations. If you need strict case matching (e.g., exclude only 'Bundle' not 'bundle'), use NOT LIKE BINARY '%bundle%'.

Example Behavior:

  • A product titled "Beginner Python" will become "Beginner Python course".
  • A product titled "Web Dev Bundle" will remain completely unchanged.

内容的提问来源于stack exchange,提问作者Eoin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:32:44