Skip to content

Commit

Permalink
自动提交
Browse files Browse the repository at this point in the history
  • Loading branch information
frankelinli committed Dec 3, 2024
1 parent d5782a6 commit 9e28347
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions blog/2024/12-03-WordPress图片相对地址.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
date: 2024-12-03 16:34
slug: WordPress图片相对地址
---

可以使用WordPress内置的函数`get_site_url()`来生成相对地址。修改图片标签如下:

<!-- truncate -->



```html
<img src="<?php echo get_site_url(); ?>/wp-content/uploads/2024/12/mpwechat.jpg" alt="微信公众号二维码">
```

这样无论是在本地环境还是生产环境,地址都会自动适配当前站点URL。使用相对地址是更好的做法,因为迁移网站时不需要手动修改地址。

0 comments on commit 9e28347

Please sign in to comment.