-
Hi!
I’ve checked the forum and I’ve found a very useful code what I tried to use on my WooCommerce store.
The code is working very well but I need a small modification.
The code what I’ve found is here: https://support.rankmath.com/ticket/bulk-add-product-keyword/
The modification what I would like that It will attach not only the product name in to the focus keyword but I can give 1-2 word extra also to this.
For example if I created a product with ‘Blue car’ name then with this extension the focus keyword will be ‘Blue car’ but I would like to add for every product the extra name as ‘print’ and the end all of the product will finish with ‘print’ —> ‘Blue car print’I would like to ask your help in this because I’m not professional in php coding.
function update_focus_keywords() { $posts = get_posts(array( 'posts_per_page' => -1, 'post_type' => 'product' // With this we get only the products (WooCommerce) )); foreach($posts as $p){ $term = get_the_title($p); // With this we get the product title update_post_meta($p->ID,'rank_math_focus_keyword',$term); } } add_action( 'init', 'update_focus_keywords' );
The ticket ‘Add bulk product focus keyword’ is closed to new replies.