wp print_thumbnail function is not working

前端 未结 4 822
离开以前
离开以前 2021-01-16 19:41

wordprees print_thumbnail function is working correctly on testing server but it\'s not working on online server and giving wrong image path such as */var/www/vhosts

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-16 20:02

    I faced the same problem and had to look around a lot in search of an answer. After my host moved servers, thumbnails weren't appearing on the home page and category pages. Looking up the source showed me that the path generated for the thumbnails was incorrect. Instead of http://.. in the image paths, I was seeing absolute file paths in the server, such as /home/..

    Couple of solutions that seemed to have worked for others did not work for me.

    What did not work:

    1. Changing permissions of wp-content/uploads and all the directories under it.
    2. Changing media settings and again reverting back to original settings.
    3. Using 'the_post_thumbnail' instead of 'print_thumbnail' function helped the thumbnails come back, but I am no programmer and could not figure out how to make the_post_thumbnail function work exactly as it was working with print_thumbnail

    What worked:

    In my many searches, I read someone saying that the problem was fixed by correcting the path for 'et_images_temp_folder' in the database. I ignored this for a while since I did not understand what it meant. Later, I searched wp_options table and found that it had the following entry.

    option_name: et_images_temp_folder option_value: /home/painteds/public_html/darter/wp-content/uploads/et_temp

    When the servers were moved my home dir was changed from /home to /home3 Perhaps print_thumbnail was searching for /home folder, and was malfunctioning when it could not find it. Updating the database with the new value fixed the problem for me.

提交回复
热议问题