Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何让我的PHP代码在Wordpress的IMGSRC中工作?_Php_Html_Wordpress_Image_Src - Fatal编程技术网

如何让我的PHP代码在Wordpress的IMGSRC中工作?

如何让我的PHP代码在Wordpress的IMGSRC中工作?,php,html,wordpress,image,src,Php,Html,Wordpress,Image,Src,我一直试图在Wordpress网站上的文章缩略图自定义字段中获取一个图标的小图像。但是图像本身并没有加载,但是站点知道图像应该在那里 这是我现在的PHP代码 <?php $filepath= "<?php bloginfo('template_url'); ?>/img/downarrow.png"; $meta_value = get_post_meta( $post->ID, 'Magamistuba', true ); if (!emp

我一直试图在Wordpress网站上的文章缩略图自定义字段中获取一个图标的小图像。但是图像本身并没有加载,但是站点知道图像应该在那里

这是我现在的PHP代码

<?php 
$filepath= "<?php bloginfo('template_url'); ?>/img/downarrow.png";
$meta_value = get_post_meta( $post->ID, 'Magamistuba', true ); 
            if  (!empty( $meta_value )) {echo   '<img src="'.$filepath.'">'.$meta_value;}
            else {} 

?>

你不需要写
你不需要写



这是因为
$filepath
是一个字符串,而不是PHP代码

您必须将代码放在字符串和外部



这是因为
$filepath
是一个字符串,而不是PHP代码

您必须将代码放在字符串和外部


试试这个

$filepath = get_template_directory_uri()."/img/downarrow.png";
试试这个

$filepath = get_template_directory_uri()."/img/downarrow.png";

我以前试过这个,但效果不理想。它在我的网站上以文本和图标缩略图(而不是图像本身)的形式显示文件目录。遗憾的是,这给了我同样的结果。我以前尝试过这一点,但它并没有按预期工作。它在我的网站上以文本和图标缩略图(而不是图像本身)的形式显示文件目录。遗憾的是,这给了我同样的结果。没有按预期工作。检查我对@Rounin的回答,然后编辑帖子。没有按预期的那样工作。检查我对@Rounin的回答,然后编辑帖子。没有按预期的那样工作。检查我对@Rounin的回答,然后编辑帖子。没有按预期的那样工作。检查我对@Rounin的回答,然后编辑帖子。没有按预期的那样工作。请检查我对@Rounin的回答并编辑到帖子中。请在你的回答中添加一些解释,以便其他人可以从中学习,而不是像预期的那样工作。检查我对@Rounin的回答并编辑到帖子中。请在你的回答中添加一些解释,以便其他人可以从中学习。你试图调试这个问题的原因是什么?为什么要添加文本字符串
,您试图调试这个问题的原因是什么?为什么要添加文本字符串

$filepath = bloginfo('template_url') . '/img/downarrow.png';
<?php 
    $filepath= bloginfo('template_url') . "/img/downarrow.png";
    $meta_value = get_post_meta( $post->ID, 'Magamistuba', true );
    if  (!empty( $meta_value )) {echo   '<img src="'.$filepath.'">'.$meta_value;}
    else {}
?>
$filepath = get_template_directory_uri()."/img/downarrow.png";