Post Closed as "off-topic" by TheDeadMedic, Mark Kaplun, Mayeenul Islam, Howdy_McGee, cybmeta
3 added 33 characters in body
source | link

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.

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?

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.

2 formatted the code to make it more readable
source | link

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
    <?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>
    </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?

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?

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?

1
source | link

Using PHP for background-image property

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?