Fix the Alt properties of Wordpress Google SEO search engine to optimize missing images

Yes. wordpress Pictures add alt properties and bitle attributes to enhance the site’s presence100 degreesWaiting for the intake in the search engine. For the website. I don’t know. It’s very helpful. If you don’t know about the alt properties and bitle attributes, you can look at this article: the difference between the alt and title properties in the img label, their effects and seo effects. We can upload pictures from behind.DefinitionsProperties such as title, description, alternative text, image description, etc. of the picture, as shown in the figure below:

But it’s cumbersome and easy to ignore to add these graphic properties manually each time. You want to automatically add alt properties and bitle properties to a wordpress picture by adding the following code:WordPress ThemeThe last of the funcings.php files?> Before:

  1. /**
  2.     * Automatically add alt properties and bitle attributes to the images of WordPress articles
  3. */
  4. function image_alttitle( $imgalttitle ){
  5.         global $post;
  6.         $category = get_the_category();
  7.         $fname=$category[0]->cat_name;
  8.         $btitle = get_bloginfo();
  9.         $imgtitle = $post->post_title;
  10.         $imgUrl = “<img\s[^>*src=(?) (♪) >]*?)\\1[^>]*>”;
  11.         If…(preg_match_all(“/$imgUrl/siU”,$imgalttitle,$match,Preg_SET_ORDER)
  12.                 If…( !emptyempty($match) ){
  13.                         You know, for… ($i=0; $i < count($match); $i++){
  14.                                 $tag = $url = $match[$i][0];
  15.                                 $j=$i+1;
  16.                                 $judge = ‘/title=/’;
  17.                                 preg_match($judge,$tag,$match,PREG_OFFSET_CAPTURE);
  18.                                 If…( count($match) < 1 )
  19.                                 $altURL ♪ Alt ♪“‘.$imgtitle.” ‘…$flname.’ title=“‘.$imgtitle.’ ‘…$flname.’ ‘;
  20.                                 $url = rtrim($url,’>’);
  21.                                 $url .= $altURL.’>’;
  22.                                 $imgalttitle = str_replace($tag,$url,$imgalttitle);
  23.                         }
  24.                 }
  25.         }
  26.         return $imgalttitle;
  27. }
  28. add_filter( ‘the_content’,’image_alttitle’);

Of these codes:

  1. $altURL ♪ Alt ♪“‘.$imgtitle.” ‘…$flname.’ title=“‘.$imgtitle.’ ‘…$flname.’ ‘;

Displays the alt properties in the form of ” article title, class name, selected items ” , and the bitle attributes in the form of ” article title, classification name, selected posts.”

Code description:

1 This code automatically determines whether the picture has an alt or tile attribute, and if not, then it automatically adds analt and a bitle property to the image. 2 If the picture already has an att or title attribute, even when the value is empty, it does not add the corresponding alt and bitl properties, such as “alt=” and “title=” for the picture. 3 And now many WordPress themes have the function of automatically adding the alt and tile attributes to the picture, which you can use if your subject does not have this feature. If you don’t like the folding code, you can also use the above codes.WordPress plugins PB SEO Friendly Images, same effect.

Download Address:https://wordpress.org/plugins/pb-seo-friendly-images/

未经允许不得转载:萌萌Apprentissage » Fix the Alt properties of Wordpress Google SEO search engine to optimize missing images

Like (0) 打赏

Comments 0

Protected with IP Blacklist CloudIP Blacklist Cloud
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

//下一个脚本特效
//下一个脚本