I'm building a gallery page for a website and want to use the images from post types as background images with lightboxes. The code im using currently is this:
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<div id="inner-content" class="wrap cf">
<?php
$loop = new WP_Query( array(
'post_type' => 'sympathy-flowers',
'order' => 'ASC',
'posts_per_page' => -1
));
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="b33" style="background-image: url("<?php echo the_field('image'); ?>;">
<p>Hello World!</p>
</div>
<?php endwhile; wp_reset_query(); ?>
</div>
</div><!-- #content -->
</div><!-- #primary -->
When I refresh the page, it brings through the p tag, however the background-image is not working, how would I fix this?
Problem has since been fixed.
url(
it should be?>);">
– majick May 19 '16 at 10:15wp_reset_postdata();
instead ofwp_reset_query();
the reason for this can be found here wp_reset_postdata(); or wp_reset_query(); after custom loop – Stephen May 19 '16 at 10:45