打开类别的图表协议

时间:2015-03-22 15:24:03

标签: wordpress facebook-opengraph opengraph open-graph-protocol

我在我的WordPress网站上添加了开放图形协议。它在帖子/页面上工作正常,但是,当涉及到类别页面时,我想将类别名称作为og:title的值,而是取出当前类别下最新帖子的帖子标题。如何将当前类别的类别名称取为og:title?

的值
<meta property="og:title" content="<?php the_title(); ?>"/>
<meta property="og:description" content="<?php echo strip_tags(get_the_excerpt($post->ID)); ?>" />
<meta property="og:url" content="<?php the_permalink(); ?>"/>
<?php $fb_image = wp_get_attachment_image_src(get_post_thumbnail_id( get_the_ID() ), 'thumbnail'); ?>
<?php if ($fb_image) {  ?>
    <meta property="og:image" content="<?php echo $fb_image[0]; ?>" />
<?php } else { ?>
    <meta property="og:image" content="<?php echo bloginfo( 'template_directory' ); ?>/images/amk_default.jpg" />
<?php } ?>
<meta property="og:type" content="<?php
      if (is_single() || is_page()) { echo "article"; } else { echo "website";} ?>"/>
<meta property="og:site_name" content="<?php bloginfo('name'); ?>"/>

1 个答案:

答案 0 :(得分:0)

看到你的努力会很高兴,但无论如何......

以下是使用函数的链接

http://codex.wordpress.org/Function_Reference/get_query_var http://codex.wordpress.org/Function_Reference/get_cat_name

echo get_cat_name( get_query_var('cat') );