Modify the WordPress-related article plug-in to add custom image addresses in batches.

Source: Internet
Author: User
WordPress-related log plug-ins: WordPressRelatedPosts, which is also a plug-in made by boiled fish. one function can display thumbnails through custom fields. for a new blog, you can add them slowly, however, for a WordPress-Related log plug-in that already has hundreds of thousands of logs: WordPress Related Posts, which is also a plug-in made by boiled fish, one function can display thumbnails through custom fields, for a new blog, you can add it slowly, but for a log that already has hundreds of thousands, if you really need the relevant log to show only the image, instead of the title type, at this time, you can modify the fields one by one. it takes a long time and is exhausted. I thought of the modification. after the modification based on the source code, everything works normally. As for whether it is beautiful or not, you need to modify it yourself. after all, you need to modify PHP and design it well.

Defaults to _s.jpg
It is applicable not only to flickr, but also to some large websites. the built-in image library of wordpress can also be used. However, you need to manually modify the code to replace the suffix.
Note:
Just a few small changes. The plug-in source code comes from boiled fish.
You do not need to check Related Posts with Thumbnail for plug-in settings.

: Related logs show thumbnail only plug-in: http://www.yisougou.com/download/relatedpost-only-display-first-images.rar

Where you may need to change:


$ Content = $ related_post-> post_content;

Preg_match_all ('| I', $ related_post-> post_content, $ matches );

$ Img_src = $ matches [1] [0]; // first photo
If (eregi ("flickr.com", $ img_src )){
$ Img_url = str_replace (". jpg", "_s.jpg", $ img_src );
} Else {
$ Img_url = $ img_src;
}

You can set how to replace the image suffix. the above only captures the first image of each article.

And

$ Output. = 'id). '"title ="'. wptexturize ($ related_post-> post_title). '"> ';

You can set the image display format as shown in the preceding figure.

Effect reference address: http://www.babyshoot.cn/2010/01/22/dreaming-of-forever.html

In this way, you do not need to modify the thumbnail image address of the custom field in each article.

Source code: http://fairyfish.net/2007/09/12/wordpress-23-related-posts-plugin/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.