Remove all stop words from old permalinks

This script will do the job: function wpse_287807_replace_url() { // Get all posts $query = new WP_Query(array( ‘post_type’ => ‘post’, ‘posts_per_page’ => -1, )); $posts = $query->get_posts(); foreach ($posts as $post) { // Get permalink $url = $post->post_name; // Stop words array $stop_words = array( ‘-a-‘, ‘-the-‘, ‘-of-‘, ); // Replacement $replacement=”-“; // Replace url … Read more

Export Yoast Keywords from MySQL/phpMyAdmin

This query pulls the post id, title, permalink, and focus keywords. You could modify this to pull the post meta description and title as well if you wanted. Change post_type to page if you want to pull pages. SELECT wpp.post_title, wpp.ID, wpp.post_date, mt1.meta_value as focus_keyword, REPLACE( REPLACE( REPLACE( REPLACE( wpo.option_value, ‘%year%’, DATE_FORMAT(wpp.post_date,’%Y’) ), ‘%monthnum%’, DATE_FORMAT(wpp.post_date, … Read more

Is there a straight-forward way to provide a meta description tag via Yoast SEO, programmatically, without relying on the admin panel?

Way overthinking it: <?php add_filter(‘wpseo_opengraph_desc’, function () use (&$data) { $seo_intro = trim($data->seo_intro); if ($seo_intro === ”) { $seo_intro = “{$data->name} – {$data->title}”; } return esc_attr(wp_strip_all_tags(stripslashes(do_shortcode($seo_intro)))); }, PHP_INT_MAX); ?> Essentially, hijack the content with a filter (since that’s what Yoast is using to derive the description) and make sure it’s the last filter to be … Read more

wp_get_canonical_url showing first url of the post for custom page

This is because wp_get_canonical_url can only be used on posts, and cannot be used for tags authors archives etc. Returns the canonical URL for a post. https://developer.wordpress.org/reference/functions/wp_get_canonical_url/ More specifically, no equivalent exists for tag archives because archives and listings do not have canonical URLs. A canonical URL indicates to a search engine the correct and … Read more

Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)

Create custom action in function.php, which checks current page type (if it’s category or tag page). function hidden_term_name_action() { if( is_category() || is_tag() ){ $term_id = get_queried_object_id(); $term = get_term($term_id); if($term){ echo sprintf(‘<h1 style=”display:none;”>%s</h1>’, esc_attr($term->name)); } } } add_action(‘hidden_term_name’, ‘hidden_term_name_action’); Paste this code in header.php, which fires this action and pastes term title inside hidden … Read more