php 使用All in one SEO包的wordpress的结构化数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 使用All in one SEO包的wordpress的结构化数据相关的知识,希望对你有一定的参考价值。

<!--WP loop-->
<?php 
  if ( have_posts() ) : while ( have_posts() ) : the_post(); 
  $sns_url = urlencode(get_permalink());
  $image_id = get_post_thumbnail_id(); 
  if(!empty($image_id)){

    $image_url = wp_get_attachment_image_src($image_id, true)[0]; 
    $image_size = wp_get_attachment_metadata($image_id,false);
    $image_height = $image_size['height'];
    $image_width = $image_size['width'];

  }else{
    $image_url = get_template_directory_uri().'/img/common/zdo_defautl_thumb.png';//アイキャッチを指定しない時のデフォルトサムネイルのパス
    $image_height = 960;
    $image_width = 720;
  }
  $description = htmlspecialchars(get_post_meta($post->ID, _aioseop_description, true),ENT_QUOTES); //All in One SEO からdescriptionを取得
?>

<script type="application/ld+json"> 
{ 
  "@context": "http://schema.org", 
  "@type": "BlogPosting", 
  "mainEntityOfPage":{ 
    "@type":"WebPage", 
    "@id":"<?php the_permalink(); ?>" 
  }, 
  "headline": "<?php the_title();?>", 
  "image": { 
    "@type": "ImageObject", 
    "url": "<?php echo $image_url; ?>", 
    "height": <?php echo $image_height?>, 
    "width": <?php echo $image_width?> 
  }, 
  "datePublished": "<?php the_time('Y/m/d') ?>", 
  "dateModified": "<?php the_modified_date('Y/m/d') ?>", 
  "author": { 
    "@type": "Person", 
    "name": "<?php bloginfo('name'); ?>" 
  }, 
  "publisher": { 
    "@type": "Organization", 
    "name": "<?php bloginfo('name'); ?>", 
    "logo": { 
      "@type": "ImageObject", "url": "<?php echo get_template_directory_uri()?>/img/common/logo.png"
    }
  }, 
  "description": "<?php echo $description?>" 
} 
</script> 

以上是关于php 使用All in one SEO包的wordpress的结构化数据的主要内容,如果未能解决你的问题,请参考以下文章

html ALL-IN-ONE - Facebook PHP SDK 4.0.x

FileZilla FTP & SFTP All In One

[转帖]Kubesphere all-in-one 安装方式.

如何使用 Xbox Series X 驾驶游戏练习车技 All In One

使用 Linux 命令如何恢复被覆盖的文件 All In One

TOML All In One