7
votes
Accepted
Where does Yoast SEO plugin sets the site/page title?
There's a wpseo_title filter you can hook into. Example:
add_filter('wpseo_title', 'add_to_page_titles');
function add_to_page_titles($title) {
$title .= $addToTitle;
return $title;
}
7
votes
Yoast SEO breadcrumbs: how to create a filter that uses the url slug for breadcrumb titles
Yoast does have a filter for you to use. See here:
https://gist.github.com/jmcclellan/b2d97ffee0e924e28fa1
I used this to add "parent" pages to custom post types. We wanted to use pages as our ...
6
votes
How to rewrite title- and meta-description templates for page templates in Yoast Plugin
You may consider the use of both filter wpseo_metadesc (for meta description) and wpseo_title (for title). The idea is to change the values of title and/or description depending if you meet some ...
5
votes
Accepted
Query Post Based of Yoast Primary Category Class
Yoast SEO stores the primary term ID as the post meta field _yoast_wpseo_primary_{taxonomy}. Knowing this you can use a meta query to get all posts with primary category ID X:
$query = new WP_Query([
...
4
votes
make the url unlimited
You might think it's 39 characters long, but it's actually 332 characters long.
This is the real URL you're trying to use:
https://sitename.com/%D8%A8%D8%B1%D9%85%D8%AC%D8%A9-%D8%AA%D8%B5%D9%85%D9%...
4
votes
Exclude custom post_type in sitemap generation?
If you are using functions.php script to register custom post type, you should declare false to 'has_archive' => true,.
function custom_post_type() {
$labels = array( ... );
$args = array(
...
4
votes
How to override the title tag for woocommerce endpoints?
If you added custom WC endpoints on init, you can use something like this instead to check for endpoints (adjust accordingly if you're using Yoast):
function add_custom_endpoints_to_title( $...
4
votes
Custom Yoast Breadcrumbs URL
That's an unusual setup - Yoast usually recognizes the right permalinks. You may want to consider changing the way you set up your custom post type, so that it has the desired names and URLs to begin ...
4
votes
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/...
3
votes
Accepted
Every new post/draft has a custom field variable "yst_is_cornerstone" showing
Yes, this is a new Yoast SEO feature. It's a checkbox, so as long a you don't select it in the SEO-metabox, the value will be zero/empty. I presume it's overwritten every time the post is saved, hence ...
3
votes
Set Custom Post feature image as og:image
you can make your own plugin, or just use it in your functions.php
add_action('wp_head', 'dgsoft_fb');
function dgsoft_fb(){
if( is_single() ) {
echo '<meta property="og:image" content=...
3
votes
Accepted
Can I change the contents of a description meta tag generated by Yoast?
Take a look at WordPress SEO API Docs it appears you can modify the meta description tag will somthing like:
add_filter('wpseo_metadesc', function($description){
if ($wtv_language == 'wtv') {
...
3
votes
How can I change the <head> tag contents of individual Wordpress posts?
I would read this article, its from Yoast. I don't think you are understanding what the focus keyword feature does. This article talks about that as well as how adding the keyword meta tag is a ...
3
votes
Accepted
Wrong Canonical url link
You need to reset your indexables. There are a couple of ways to do this - you can use a WP-CLI command (wp yoast index), or you can use the Yoast Test Helper plugin.
If you install the Yoast Test ...
3
votes
Accepted
Can't print Yoast meta description into page template (syntax error, unexpected '.')
There is indeed an unwanted ; (semicolon) in your function (try to look at line 99 in the twentytwentyone-child/functions.php file) which likely is the cause to the syntax error. So just remove that ; ...
2
votes
Edit title-tag in wp_head with yoast seo
I don't think adding <span itemprop> to the <title> is a good idea... If you can not use any existing tags like <h1> for that, you may consider adding meta tag: <meta itemprop="...
2
votes
remove rel=next on home page but not others
Here is the answer:
function bg_disable_front_page_wpseo_next_rel_link( $link ) {
if ( is_front_page() ) {
return false;
}
return $link;
}
add_filter( 'wpseo_next_rel_link', '...
2
votes
Yoast SEO Calling content filters 2 additional times
The core of your problem is that the_content is a filter not an action, and it is supposed to return values, not echo them.
As for the "called number of times" part of the question, yes any hook can ...
2
votes
Exclude custom post_type in sitemap generation?
If you need a filter solution:
add_filter( 'wpseo_sitemap_exclude_post_type', 'your_prefix_exclude_cpt_from_sitemap', 10, 2 );
function your_prefix_exclude_cpt_from_sitemap( $value, $post_type ) {
...
2
votes
Exclude custom post_type in sitemap generation?
This question has been asked a long time ago, but the answer is kind of simple:
Go to SEO --> Search Appearance.
Select tab Contenttypes.
Scroll down, here you can display or hide custom post types ...
2
votes
Where does Yoast SEO plugin sets the site/page title?
Where does Yoast SEO plugin sets the site/page title?
Yoast SEO plugin adds two hooks that filter the title.
add_filter( 'pre_get_document_title', array( $this, 'title' ), 15 );
add_filter( '...
2
votes
Display Yoast WordPress SEO title in archive template
Getting the focus keyword for categories and tags
To get the focus keyword of a Category or Tag programmatically, you can use either of these two methods:
/** Method 1. Tap into the ...
2
votes
How to Modify Breadcrumb Page Names for Specific Pages?
We generally don't answer plugin-specific questions here so you may find more help in a Yoast-specific forum. To point you toward the right direction, though, there is a filter called ...
2
votes
Post content blank after disabling Yoast SEO
Turns out the single-post.php template was missing a call to the_post(). Since that function initializes all the postdata used by functions like the_content(), WordPress had nothing to display.
As ...
2
votes
Accepted
Filter yoast canonical add_action priority
You would need to look in the Yoast plugin to find what the global class is that is referred to as $this, so that you can access it outside the class context. If it was for example, $wpseo, in your ...
2
votes
Accepted
Facebook og:image issues after https change
The https change was not the cause. Actually - coincidentally - the W3 Total Cache was updated on the same day, and the Minify setting was breaking lines between meta and property words on the HTML, ...
2
votes
htaccess: Remove trailing slash from URL ending with .xml/ only
If you're outputting a sitemap, there's no reason to wait for the query for your page- which is what is producing the redirect.
Hook an earlier action and you won't need anything to counter the ...
2
votes
How to parse Yoast SEO Snippet Variables
Ok here is how I parsed the snippets in case anyone else needs to know
$id = get_the_ID();
$post = get_post( $id, ARRAY_A );
$yoast_title = get_post_meta( $id, '_yoast_wpseo_title', true );
$...
2
votes
Accepted
When does the Yoast SEO filter hook wpseo_sitemap_urlimages fire?
What I wanted to say in my previous comment:
This hook is only fired when the sitemap is being built. After that, it's cached and always served from cache. That means you'll never see any change on ...
2
votes
Accepted
Yoast SEO settings unavailable in an archive page from wordpress plugin
Yoast SEO can have limitations for archive pages. Try a different SEO plugin such as Rank Math perhaps.
Your other option would be to open the archive.php file of your theme and add your custom code ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
plugin-wp-seo-yoast × 245seo × 54
plugins × 44
sitemap × 19
php × 18
title × 15
permalinks × 11
plugin-development × 10
post-meta × 10
filters × 9
rel-canonical × 9
google-xml-sitemaps × 9
breadcrumb × 8
custom-post-types × 7
robots.txt × 7
functions × 6
customization × 6
categories × 6
url-rewriting × 6
wp-title × 6
google-search × 6
custom-taxonomy × 5
theme-development × 5
images × 5
themes × 5