Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.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:Can';t使用get_the_id()获取文章标记中的URL;_Php_Html_Wordpress - Fatal编程技术网

Php Wordpress:Can';t使用get_the_id()获取文章标记中的URL;

Php Wordpress:Can';t使用get_the_id()获取文章标记中的URL;,php,html,wordpress,Php,Html,Wordpress,我有这个标记 <article id="post-<?php the_ID(); ?>" <?php post_class($masonry_item_sizing); ?> style="background: url("<?php echo get_post_meta(get_the_ID(), 'sponsors_logo_file_url', true); ?>")">

我有这个标记

                    <article id="post-<?php the_ID(); ?>" <?php post_class($masonry_item_sizing); ?> style="background: url("<?php echo get_post_meta(get_the_ID(), 'sponsors_logo_file_url', true); ?>")">

                        <div class="inner-wrap animated">
                            <div class="post-content">
                                <img src="<?php echo get_post_meta(get_the_ID(), 'sponsors_logo_file_url', true); ?>">
                                    <p><?php the_title(); ?></p>
                                    <p><?php echo get_post_meta(get_the_ID(), 'event_location', true); ?></p>
                                    <p><?php echo get_post_meta(get_the_ID(), 'event_date_time', true); ?></p>
                                <div class="post-meta <?php echo $extra_class; ?>">


                     </div><!--/post-meta-->


                    </div>
                    </div>
                   </article>
”但不是图像的直接链接

为什么会发生这种情况?我如何解决

谢谢。

最好使用:

background-image: url() 
反而

background: url("")
最终代码:

<?php $bg = get_post_meta(get_the_ID(), 'sponsors_logo_file_url', true); ?><article id="post-<?php the_ID(); ?>" <?php post_class($masonry_item_sizing); ?> style="background-image: url(<?php echo $bg; ?>)">
<div class="inner-wrap animated">
    <div class="post-content">
        <img src="<?php echo $bg; ?>">
            <p><?php the_title(); ?></p>
            <p><?php echo get_post_meta(get_the_ID(), 'event_location', true); ?></p>
            <p><?php echo get_post_meta(get_the_ID(), 'event_date_time', true); ?></p>
        <div class="post-meta <?php echo $extra_class; ?>"></div><!--/post-meta-->
    </div>
</div>

background: url("")
<?php $bg = get_post_meta(get_the_ID(), 'sponsors_logo_file_url', true); ?><article id="post-<?php the_ID(); ?>" <?php post_class($masonry_item_sizing); ?> style="background-image: url(<?php echo $bg; ?>)">
<div class="inner-wrap animated">
    <div class="post-content">
        <img src="<?php echo $bg; ?>">
            <p><?php the_title(); ?></p>
            <p><?php echo get_post_meta(get_the_ID(), 'event_location', true); ?></p>
            <p><?php echo get_post_meta(get_the_ID(), 'event_date_time', true); ?></p>
        <div class="post-meta <?php echo $extra_class; ?>"></div><!--/post-meta-->
    </div>
</div>