0

このコードを関数に挿入しました。これは私のWordPressのPHPファイルです。それが基本的に行うことは、

ユーザーが Pinterest PIN IT ボタンをクリックすると、最初の画像のブログ投稿ページがチェックされ、Pinterest にピン留めされるように返されます

誰かがコードを変更して、ブログ投稿ページのすべての画像を完全に無視し、代わりにアイキャッチ画像を選択することは可能ですか?

最初の画像関数をキャッチします。

function catch_that_image() {
  global $post, $posts;
  $first_img = '';
  ob_start();
  ob_end_clean();
  $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
  $first_img = $matches [1] [0];

  if(empty($first_img)){ //Defines a default image
    $first_img = "http://www.bendaggers.com/wp-content/themes/Lord%20of%20Avernus%20-%20Abaddon/Images/Deafult_Img.png";
  }
  return $first_img;
}

ワードプレスの主な画像:

<?php the_post_thumbnail(); ?> 
4

1 に答える 1