我想更改jetpack默认为空。og上的jpg atribute:图像。我读了一些关于这门学科的文章,但没有真正帮助我。以下是一些尝试:
/**
* Override the default OpenGraph tags
*/
add_filter( \'jetpack_open_graph_tags\', function( $tags ) {
$tags[\'twitter:site\'] = \'@ourhandle\';
$tags[\'twitter:creator\'] = \'@ourhandle\';
$tags[\'og:site_name\'] = \'Our Site Name\';
// the og:image key defaults to the featured image. if the value is
// not set, define it as an array. if the value is set, assume it is
// the featured image (or has been previously filtered)
if ( ! isset( $tags[\'og:image\'] ) ) {
$tags[\'og:image\'] = array();
}
$tags[\'og:image\'] = (array)$tags[\'og:image\'];
if ( is_a_particular_blog() ) {
$blog = custom_get_blog();
$tags[\'og:image\'][] = custom_the_term_image_src( $blog->term_taxonomy_id );
} else {
foreach ( get_coauthors() as $coauthor ) {
$tags[\'og:image\'][] = custom_get_coauthor_avatar_uri( $coauthor->ID, true );
}
}
$tags[\'og:image\'][] = \'http://static.oursite.org/images/oursite_opengraph_360x185.png\';
return $tags;
} );
function fix_jp_og_bugs ($og_tags)
{
$og_tags[\'twitter:site\'] = \'@laszlop\';
if (0 == strcmp ($og_tags[\'og:image\'],
"https://s0.wp.com/i/blank.jpg")
{
unset ($og_tags[\'og:image\']);
}
return $og_tags;
}
add_filter (\'jetpack_open_graph_tags\', \'fix_jp_og_bugs\', 11);
所以我想在主页上看到这个元标签:
<meta property="og:image" content="http://www.neocsatblog.mblx.hu/wp-content/uploads/2013/04/cropped-jobbbföld-maszk-21.png" />
而不是这个:
<meta property="og:image" content="https://s0.wp.com/i/blank.jpg" />
我将Ifeature主题与最新的wordpress和jetpack插件结合使用<我的网站是:
http://neocsatblog.mblx.hu/
SO网友:Gaia
这是official way to do it
Create a 200x200 image and place it in a publicly accessible URL in your site. 最好的方法是使用Wordpress的内置媒体上传程序。
然后添加到主题的功能中。php文件以下代码段之一:
(A)for making the chosen image show up on the home page:
function fb_home_image( $tags ) {
if ( is_home() || is_front_page() ) {
// Remove the default blank image added by Jetpack
unset( $tags[\'og:image\'] );
$fb_home_img = \'YOUR_IMAGE_URL\';
$tags[\'og:image\'] = esc_url( $fb_home_img );
}
return $tags;
}
add_filter( \'jetpack_open_graph_tags\', \'fb_home_image\' );
(B)
for making the chosen image show up on any page that doesn\'t have a featured image:function custom_jetpack_default_image() {
return \'YOUR_IMAGE_URL\';
}
add_filter( \'jetpack_open_graph_image_default\', \'custom_jetpack_default_image\' );