dst3605528 2016-03-29 16:40 采纳率: 0%
浏览 35
已采纳

未定义的功能仅限主页上的the_post_thumbnail

I have a strange problem where on my local (Ubuntu) setup, as well as our production and staging environments (also Unix) everything works fine. But on my colleagues (Windows) environment the error "undefined function the_post_thumbnail" shows up on the front-page (and only the front-page).

The strange thing is that it only happens on the front-page even though post thumbnails are being used on more or less every page.

We are of course adding post thumbnail support (through add_theme_support('post-thumbnails')). This was (incorrectly I believe (now)) done on the 'init' hook but we have tried 'after_theme_setup' too (both works for me - none for him)).

We tried die() inside the same function that calls add_theme_support() and the die-text does show up on the front-page which tells me all the code in that function is being run.

How come it works on all other pages but not on the home page (not sure if it's worth mentioning but we are using a static front-page along with the front-page.php template as opposed to a blog home page)? How come it's specific to his machine?

Has anyone else experienced this?

  • 写回答

1条回答 默认 最新

  • doulu1020 2016-03-30 09:00
    关注

    Ok, so apparently I was incorrect in two things:

    1) My colleague did not use the latest version of WP and 2) It wasn't the_post_thumbnail he got the error on but the_post_thumbnail_url

    That explains it because the_post_thumbnail_url is a new function from WP4.4.

    Leaving this answer here in case someone else runs into this problem too.

    Edit: Oh, and the reason it only failed on the home page was because that's the only place the featured image was used as a background image (hence using the_post_thumbnail_url as opposed to (the not recently added) the_post_thumbnail)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 我想在一个软件里添加一个优惠弹窗,应该怎么写代码
  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流