-
Hello, we have implemented your automatic focus key from product title code but it seems to have added focus keywords of other prodct names. That is focus keyword for product A is B while that of product B is A.
We are also getting the following error in log
/home/eef/public_html/website.co.uk/wp-content/themes/store/functions.php on line 400, pointing to an error in your code.
/**
* Function to automatically update the focus keyword with the product title
*/
function update_focus_keywords()
{
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'product' //replace post with the name of your post type
));
foreach ($products as $p) {
update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_title($p->ID)));
}
}
add_action('init', 'update_focus_keywords');
The ticket ‘Automatic focus keywords’ is closed to new replies.
