最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugin development - plugin_dir_path wrong url

programmeradmin2浏览0评论
  echo "background-image: url(" . plugin_dir_path( __FILE__ ) . '/images/bag.png);';

output:

url(/home/deniztas/oneclick.deniz-tasarim.site/wp-content/plugins/my_post_plugin-bag2-solda/widgets//images/bag.png)

I want this:

oneclick.deniz-tasarim.site/wp-content/plugins/my_post_plugin-bag2-solda/widgets//images/bag.png)

why /home/.. comes to my url?

  echo "background-image: url(" . plugin_dir_path( __FILE__ ) . '/images/bag.png);';

output:

url(/home/deniztas/oneclick.deniz-tasarim.site/wp-content/plugins/my_post_plugin-bag2-solda/widgets//images/bag.png)

I want this:

oneclick.deniz-tasarim.site/wp-content/plugins/my_post_plugin-bag2-solda/widgets//images/bag.png)

why /home/.. comes to my url?

Share Improve this question edited Mar 24, 2020 at 2:15 WordPress Speed 2,2833 gold badges19 silver badges34 bronze badges asked Mar 23, 2020 at 21:06 Ahmet TaşAhmet Taş 112 bronze badges 1
  • 1 developer.wordpress/reference/functions/plugin_dir_url – Michael Commented Mar 23, 2020 at 21:47
Add a comment  | 

1 Answer 1

Reset to default 2

because you are using the wrong function. You should use:

plugin_dir_url( __FILE__ ) . 'images/bag.png';

Also remove the extra forward slash before images:

/images
发布评论

评论列表(0)

  1. 暂无评论