wordpress - 更改 og :url in WordPress SSL site to point to http

标签 wordpress facebook ssl

我最近转向了 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 以使更改生效:

https://developers.facebook.com/tools/debug/sharing

关于wordpress - 更改 og :url in WordPress SSL site to point to http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41313772/

相关文章:

javascript - 使用 Facebook Open Graph API 创建对象

ios - 将照片上传到 Facebook 粉丝专页

php - 将 FB 帐户与我网站上的帐户相关联

ssl - Kubernetes NGINX 入口 Controller 未获取 TLS 证书

ssl - Jetty 教程中的 SSL 密码

html - 我可以自定义编辑 WordPress 图像页面吗?

php - 在 Woocommerce 结帐中将 "Local Pickup"文本更改为其他内容

php - WordPress - 类别未显示所有帖子

ssl - 从 cpanel 修复 ssl_error_rx_record_too_long

mysql - 透视 SQL 数据 - 将行分组为列