据我所知,您需要帮助构建if逻辑?而且php标记的使用看起来也不正确。
这有帮助吗-
<?php
if(!is_single()){
if(is_home() || is_front_page()){ // not sure if you have set a static page as your front page
echo \'<meta property="og:url" content="\'.bloginfo(\'url\'); .\'" />\';
}elseif(is_tag()){
echo \'<meta property="og:url" content="\'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; .\'">\';
}
}
?>
================这是完整的代码========================
function wpc_fb_opengraph() {
$wpc_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), \'large\');
?>
<?php echo "\\n<!-- Start of OG Tags from DougTheme 2013 -->\\n"; ?>
<meta property="og:image" content="<?php if (function_exists(\'catch_that_image\')) {echo catch_that_image(); }?>" />
<meta property="fb:admins" content="XXXXX"/>
<meta property="fb:app_id" content="XXXXXXXXXX">
<meta property="og:site_name" content="<?php bloginfo(\'name\'); ?>" />
<meta property="og:description" content="<?php if ( is_singular() ) { echo strip_tags(get_the_excerpt()); } else { echo "comments about everything"; } ?>" />
<meta property="og:title" content="<?php if ( is_singular()) { echo esc_attr( get_the_title() ); } elseif (function_exists(\'is_tag\') && is_tag()) {single_tag_title(\'Tag Archive for "\'); echo \'" - \'; echo get_bloginfo(\'name\');} else { echo get_bloginfo(\'name\'); } ?>">
<meta property="og:type" content="<?php if ( is_singular() ) { echo "article"; } else { echo "website";} ?>">
if(!is_single()){
if(is_home() || is_front_page()){ // not sure if you have set a static page as your front page
echo \'<meta property="og:url" content="\'.bloginfo(\'url\'); .\'" />\';
}elseif(is_tag()){
echo \'<meta property="og:url" content="\'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]; .\'">\';
}
}
<?php echo "\\n<!-- End of OG Tags from DougTheme 2013 -->\\n"; ?>
<?php }
add_action(\'wp_head\', \'wpc_fb_opengraph\');