WordPress.org

Forums

[resolved] [Plugin: Advanced Custom Fields] Backslashes stripped from sub_field (2 posts)

  1. seansean11
    Member
    Posted 2 years ago #

    I'm not sure if this problem is specific to the ACF plugin, but I am using the repeater field add on to create an image slider. It is working fine, except for the fact that the url for the image is stripped of its backslashes. I can't find anything about this anywhere and I'm more of a front-end guy. Please take a look. Here is my code:

    <?php
    
    	if(get_field('header_slider')) {
    
    		while(has_sub_field('header_slider')) { ?>
    			<?php $image = wp_get_attachment_image_src(get_sub_field('slider_image'), 'homepage' ); ?>
    			<div style="background-image: url("<?php echo $image[0]; ?>")">
    				<h2 class="home-title"><?php echo get_sub_field('slider_title'); ?></h2>
    				<p class="home-caption"><?php echo get_sub_field('slider_caption'); ?></p>
    			</div>
    
    		<?php }
    	}
    	?>

    this code is producing this html

    <div style="background-image: url(" http: localhost acrossamerica wp-content uploads 2012 12 slider_cali1.jpg")">
    		<h2 class="home-title">Title #2</h2>
    		<p class="home-caption">Caption #2</p>
    </div>
  2. seansean11
    Member
    Posted 2 years ago #

    Stupid mistake. I was using double quotes within double quotes in the PHP.

Topic Closed

This topic has been closed to new replies.

About this Topic