Auto generator SEO keywords or KeyPhrases as title of post
past this code on down to the function.php code
only for title
/**
* Set default focus keyphrase for all products, posts, pages, and product categories.
*/
function set_default_focus_keyphrase_for_content() {
// Check if WooCommerce is active
if (class_exists('WooCommerce')) {
// Query all products
set_default_focus_keyphrase_for_content_type('product');
// Query all product categories
set_default_focus_keyphrase_for_taxonomy('product_cat');
}
// Query all posts
set_default_focus_keyphrase_for_content_type('post');
// Query all pages
set_default_focus_keyphrase_for_content_type('page');
}
function set_default_focus_keyphrase_for_content_type($post_type) {
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1,
);
$content = new WP_Query($args);
// Loop through content
while ($content->have_posts()) {
$content->the_post();
// Set default focus keyphrase to "Today Top News" + post title (limited to 15 words), remove commas, add "Blogstour"
$title = get_the_title();
$title_words = explode(' ', $title);
$limited_title = implode(' ', array_slice($title_words, 0, 15));
$default_focus_keyphrase = '' . str_replace(',', '', $limited_title) . '';
// Update focus keyphrase
update_post_meta(get_the_ID(), '_yoast_wpseo_focuskw', $default_focus_keyphrase);
}
// Reset post data
wp_reset_postdata();
}
function set_default_focus_keyphrase_for_taxonomy($taxonomy) {
$terms = get_terms(array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
));
foreach ($terms as $term) {
// Set default focus keyphrase to "Today Top News" + term name (limited to 15 words), remove commas, add "Blogstour"
$term_name = $term->name;
$term_words = explode(' ', $term_name);
$limited_term_name = implode(' ', array_slice($term_words, 0, 15));
$default_focus_keyphrase = 'Today Top News ' . str_replace(',', '', $limited_term_name) . ' Blogstour - ' . get_bloginfo('name');
// Update focus keyphrase
update_term_meta($term->term_id, '_yoast_wpseo_focuskw', $default_focus_keyphrase);
}
}
// Hook the function to run on a specific action, e.g., 'init'
add_action('init', 'set_default_focus_keyphrase_for_content');
add txt after title replace ” Home Delivery Services by FoodSala” into your txte
/**
* Set default focus keyphrase for all products, posts, pages, and product categories.
*/
function set_default_focus_keyphrase_for_content() {
// Check if WooCommerce is active
if (class_exists('WooCommerce')) {
// Query all products
set_default_focus_keyphrase_for_content_type('product');
// Query all product categories
set_default_focus_keyphrase_for_taxonomy('product_cat');
}
// Query all posts
set_default_focus_keyphrase_for_content_type('post');
// Query all pages
set_default_focus_keyphrase_for_content_type('page');
}
function set_default_focus_keyphrase_for_content_type($post_type) {
$args = array(
'post_type' => $post_type,
'posts_per_page' => -1,
);
$content = new WP_Query($args);
// Loop through content
while ($content->have_posts()) {
$content->the_post();
// Set default focus keyphrase to "Today Top News" + post title (limited to 15 words), remove commas, add "Blogstour"
$title = get_the_title();
$title_words = explode(' ', $title);
$limited_title = implode(' ', array_slice($title_words, 0, 15));
$default_focus_keyphrase = '' . str_replace(',', '', $limited_title) . ' - Food Delivery Services by FoodSala';
// Update focus keyphrase
update_post_meta(get_the_ID(), '_yoast_wpseo_focuskw', $default_focus_keyphrase);
}
// Reset post data
wp_reset_postdata();
}
function set_default_focus_keyphrase_for_taxonomy($taxonomy) {
$terms = get_terms(array(
'taxonomy' => $taxonomy,
'hide_empty' => false,
));
foreach ($terms as $term) {
// Set default focus keyphrase to "Today Top News" + term name (limited to 15 words), remove commas, add "Blogstour"
$term_name = $term->name;
$term_words = explode(' ', $term_name);
$limited_term_name = implode(' ', array_slice($term_words, 0, 15));
$default_focus_keyphrase = 'Today Top News ' . str_replace(',', '', $limited_term_name) . ' Blogstour - ' . get_bloginfo('name') . ' Home Delivery Services by FoodSala';
// Update focus keyphrase
update_term_meta($term->term_id, '_yoast_wpseo_focuskw', $default_focus_keyphrase);
}
}
// Hook the function to run on a specific action, e.g., 'init'
add_action('init', 'set_default_focus_keyphrase_for_content');






