我最近转向了 SSL,但失去了所有 FB 点赞。我在这里看到了其他答案,即Lost all Likes while moving to HTTPS但不知道如何应用它。例如,在 Simple Facebook Plugin 中我可以看到代码:
$fbmeta['og:url'] = esc_url($permalink);
如何更改它以获取 http 版本?
最佳答案
案例一:借助插件加载混合内容
Really Simple SSL 插件具有“强制更改混合内容”,这意味着它不断强制站点上的每个链接到 http...
一些有用的功能
混合内容扫描,显示如果您还没有绿锁,您必须做什么
启用 HTTP 严格传输安全的选项
为 HSTS 预加载列表配置站点的选项
后端的混合内容修复器
在配置页面有更详细的反馈。
https://wordpress.org/plugins/really-simple-ssl/
案例 2:手动将 Facebook Open Graph 元数据添加到您的 WordPress 主题
//Adding the Open Graph in the Language Attributes
function add_opengraph_doctype( $output ) {
return $output . ' xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml"';
}
add_filter('language_attributes', 'add_opengraph_doctype');
//Lets add Open Graph Meta Info
function insert_fb_in_head() {
global $post;
if ( !is_singular()) //if it is not a post or a page
return;
echo '<meta property="fb:admins" content="YOUR USER ID"/>';
echo '<meta property="og:title" content="' . get_the_title() . '"/>';
echo '<meta property="og:type" content="article"/>';
echo '<meta property="og:url" content="' . get_permalink() . '"/>';
echo '<meta property="og:site_name" content="Your Site NAME Goes HERE"/>';
if(!has_post_thumbnail( $post->ID )) { //the post does not have featured image, use a default image
$default_image="http://example.com/image.jpg"; //replace this with a default image on your server or an image in your media library
echo '<meta property="og:image" content="' . $default_image . '"/>';
}
else{
$thumbnail_src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
echo '<meta property="og:image" content="' . esc_attr( $thumbnail_src[0] ) . '"/>';
}
echo "
";
}
add_action( 'wp_head', 'insert_fb_in_head', 5 );
其他解决方案
首先你必须更改 url 请检查 FB 指南
https://developers.facebook.com/docs/plugins/faqs#faq_1149655968420144
您需要指示 facebook 爬虫重新抓取您的 url 以使更改生效:
关于wordpress - 更改 og :url in WordPress SSL site to point to http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41313772/