WordPress.org

Forums

Linking to Images with PHP (4 posts)

  1. jlbarnes2
    Member
    Posted 11 months ago #

    Hello, all,

    I'm having trouble linking to images in my media library with PHP. On my homepage there is a slider (Flexslider) that should show three different images next to text. Here's my HTML and PHP:

    <div class="grid-8 center flexslider white-bg boxhgt-med">
        	<ul class="slides">
    	   <?php
                    $args = array(
                        'post_type' => 'featured',
    		    'orderby'=> 'rand',);
                    $the_query = new WP_Query( $args );
                    $slideshow_query = new WP_Query( $args );?>
    
                <?php if ( have_posts() ) : while ( $slideshow_query->have_posts() ) : $slideshow_query->the_post(); ?>
    
                	<li>
                        <div class="grid-4">
                            <?php echo the_content(); ?>
    
                            <h6 class="button"><a href="<?php echo the_field( 'featured_url' ); ?>">Learn More</a></h6>
                        </div>
    
                        <div class="grid-4 omega">
                            <img src="<?php the_field( 'event_image' ); ?>">
                        </div>
    
                    </li>
    			<?php endwhile; else: ?>
                               <p><?php _e('Sorry, no pages here.'); ?></p>
                            <?php endif; ?>
    		</ul>
        </div>

    All the PHP works except the images. Here's a link to one of the images that's supposed to show up.

  2. stephencottontail
    Member
    Posted 11 months ago #

    I'm not entirely familiar with how ACF works, but you may want to use print_r() or var_dump() to check the output of the_field() because I get these errors when I visit your site:

    http://livinglightlyfair.org/510,%20Krista%20Detor,%20KristaDetor_homepage,%20,%20,%20image/jpeg,%20http:/livinglightlyfair.org/wp-content/uploads/2014/08/KristaDetor_homepage1.jpg,%20345,%20259,%20Array
    Failed to load resource: the server responded with a status of 404 (Not Found)
  3. jlbarnes2
    Member
    Posted 11 months ago #

    How do I use those to check output? I'm not familiar with those commands.

    In the meantime I used the direct URL to get the page at least looking right.

    Thank you for your help!

  4. stephencottontail
    Member
    Posted 11 months ago #

    Post the output of var_dump( get_field( 'featured_url' ) ); and var_dump( get_field( 'event_image' ) ). I suspect get_field() is returning more data than you expect.

Reply

You must log in to post.

About this Topic