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>