douzhan6474 2017-06-12 07:25
浏览 86

使用Wordpress get_option设置图像的SRC

I am trying to use the get_option() function in Wordpress to set the SRC of an image in a theme file. The file is index.php, and represents the homepage.

The current image code is:

<img class="outside-collage-image" <?php echo 'src="'.get_option('article-image-1').'"'; ?>>

However, the image doesn't display, and when I inspect it, it simply says src(unknown) where it should have the proper SRC

I have tried a myriad of fixes, including leaving the SRC out of the php area and simply calling the function, but it doesn't seem to work.

The oddest part is, if I put on the page <p><?php echo 'src="'.get_option('article-image-1').'"'; ?></p> to check the output, it outputs into the <p> the proper code: src="http://image-site.com/my-image.jpg" (obviously the link to the image is fake, but the point is, it's a valid link.)

Any idea what could be causing this?

  • 写回答

2条回答

  • dongtou2016 2017-06-12 07:35
    关注

    You can try this to get the image article-image-1.jpg in your root.

     <img class="outside-collage-image" src="<?php echo get_site_url().'/article-image-1.jpg'; ?>">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办