Closed youngnaturists closed 7 years ago
I just checked your website. I saw following in HTML source:
URL .../feminism-womens-issues/page/2/:
<!-- This site is optimized with the Yoast SEO plugin v4.0.2 - https://yoast.com/wordpress/plugins/seo/ -->
<title> .... 2</title>
<meta name="description" content="..."/>
<meta name="robots" content="noindex,follow,noodp"/>
<meta name="keywords" content="..."/>
<link rel="prev" href=".../feminism-womens-issues/" />
<link rel="next" href=".../feminism-womens-issues/page/3/" />
I don't see canonical and og:url tags. It's weird and it seems as conflict with some plugin or the theme. You can see that exists next and prev URLs. I see that sitemap doesn't contain first URL (where you have manually set canonical URL) which works as should.
I'm copying message related to plugin conflicts: Sometimes strange behavior may be caused by a plugin or theme conflict. The fastest way to rule out conflicts is to deactivate all non-Yoast plugins and switch to a standard theme like Twenty Sixteen. If this resolves the issue, you have a conflict and should activate one plugin at a time until you locate the conflict. Finally, after all plugins are active, switch to your theme. This will narrow down the conflict to a specific plugin or a theme conflict.
If you are unfamiliar with checking for conflicts, we wrote a small guide that will walk you through the steps. You can find it here: https://kb.yoast.com/kb/how-to-check-for-plugin-conflicts/
We understand if you wouldn't want to deactivate your plugins and switch themes on a production site, so it may be preferable that you set up a staging environment for your tests.
If you're not familiar with a staging site, this article will help you get started: http://www.wpbeginner.com/wp-tutorials/how-to-create-staging-environment-for-a-wordpress-site/
Can you please inform us of the results?
We did as suggested with testing for conflicts, but came up with nothing... :( So what do you suggest?
I can reproduce your issue if I add following code:
add_filter( 'wpseo_opengraph_url', '__return_false' );
add_filter( 'wpseo_canonical', '__return_false' );
Basically, I can't see your code and it's hard to find this. Also, I don't know your versions of WP, PHP and other plugins. I see that you have customized theme.
The best which I can suggest is to you create PHP script (eg. canonical-test.php) with following content:
<?php
// require wordpress
define('DOING_AJAX', false);
define('WP_USE_THEMES', true);
define('QM_DISABLED', true);
define('DONOTCACHEPAGE', true);
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('WP_DEBUG_LOG', false);
$_SERVER['REQUEST_URI'] = '/';
$_SERVER['REQUEST_METHOD'] = 'GET';
// Load the WordPress library.
require_once( dirname(__FILE__) . '/wp-load.php' );
// Set up the WordPress query.
wp();
// basic init for templates
do_action( 'template_redirect' );
echo '<pre>';
global $wp_filter;
echo "Debug info for filters\n";
if ( isset( $wp_filter['wpseo_canonical'] ) ) {
var_dump( $wp_filter['wpseo_canonical'] );
}
echo "Try to init Yoast\n";
$wpseo_front=WPSEO_Frontend::get_instance();
$wpseo_front->front_page_specific_init();
echo "Test Yoast API\n";
echo "Canonical URL\n";
$url = $wpseo_front->canonical( false, true, true );
var_dump( $url );
echo '</pre>';
Upload it in your root directory (where is index.php, wp-load.php,...), Then try to run this script by typing http://....../canonical-test.php
It shows debug info for wpseo_canonical hook (possible root of this issue) and then try to run canonical with $no_override = true
which shows URL regardless previous filter.
PS. I don't know your knowledge of PHP, FTP,... Maybe it's too complex test. You can install Query monitor or debug objects (it doesn't work on WP 4.7) for more debugging.
I want to apologize for not getting back to you any sooner, @youngnaturists. Unfortunately we cannot reproduce this issue.
If I understand correctly you've checked for a plugin conflict. Did you check for a theme conflict as well? As this is such a specific issue and we're not sure if this bug could be present on other people's sites, please check this article we've written about writing a bug report.
Please let us know if the issue still persists with a theme such as twentysixteen or twentyseventeen.
Closing due to inactivity. If this issue is still relevant, please respond with requested information.
Just wanted to contribute here, because this is relatively high on the google search results, and while hopefully @youngnaturists has resolved this issue, I'm hoping to help people with the same issue in the future.
Before checking for plugin and theme conflicts, please simply check whether the setting Discourage search engines from indexing this site under Settings > Reading is checked. If it is checked, you will likely see <meta name="robots" content="noindex,follow">
in your site's header, and it seems that there will be no canonical url set by Yoast SEO.
I am seeing this on one of my sites, too—on my local test site and on the corresponding online test site (copied with Duplicator). Other websites (same version of WordPress and Yoast SEO) are fine, on the same local machine, too.
A bespoke theme as well as twentyseventeen are affected.
It does work fine (canonical shown) with all plugins activated, until I activate Yoast—that makes the canonical disappear (only on this one site).
I have diff
ed all the Yoast files against the ones of another working site—all of them are identical!
Also optimized the database with WP-Optimize (just for good measure).
So I don't know what to try next …
WordPress 4.9.8 Yoast SEO 8.2
The script from @stodorovic does show the canonical:
Debug info for filters
Try to init Yoast
Test Yoast API
Canonical URL
string(21) "https://example.test/"
I had the same issue and it did come down to some conflicts. If you just want to bypass it and put in a hot fix, you can add this to your functions.php file.
Better late than never.
Cheers.
function addYoastCanonical(){
global $post;
$meta = get_post_meta( $post->ID, '_yoast_wpseo_canonical', true );
if($meta){
echo '<link rel="canonical" href="' . $meta . '" />';
}
}
add_action( 'wp_head', 'addYoastCanonical');
@cMadders thank you so much, mate! You've done my day ;)
What did you expect to happen? When we place the canonical in the field in the back-end, it should generate a canonical tag in the source code.
What happened instead? The URL we enter still shows up in the canonical field, but there's no tag.
How can we reproduce this behavior? In the edit page of a post, in the Yoast SEO box, go to the Canonical URL field under "Advanced", enter URL, click update. The URL appears in the field, but when you go to view source, there is no canonical tag (new or old).
Can you provide a link to a page which shows this issue? We placed a canonical in the back end of this page: https://youngnaturistsamerica.com/labiaplasty-young-girls-vagina-labia-body-modification-part-two/ pointing it here: https://youngnaturistsamerica.com/labiaplasty-new-vagina-cosmetic-surgery-trend-for-girls/ (and it doesn't appear in source code)
Technical info