• Resolved franclin

    (@franclin)


    The idea is one big box that contains a thumbnail image and title. Click anywhere on the big box and off you go. ie click the image, text or background.

    Can I grab the external URL from the uploaded image? I want to make it dead simple for the authors to input that URL. I was thinking they could upload an image and input the external URL into the “link URL” when they upload the image. If I was then able to grab that I could use that as my box and text url.

    I think the code goes something like this:

    <?php
    query_posts('category_name=press');
    
    global $more;
    // set $more to 0 in order to only get the first part of the post
    $more = 0; 
    
    // the Loop
    while (have_posts()) : the_post();
    ?>
    <div id="pressEntry">
    <a href="#"><!-- How do I get the link? Can it be taken from the image information -->
    <div id="title"><?php the_title(); ?></br></a></div>
    <?php the_content(''); ?>
    </a>
    </div><!-- close press entry -->
    
    <?php
    endwhile;
    ?>

Viewing 1 replies (of 1 total)
  • Thread Starter franclin

    (@franclin)

    While reading up on custom fields I accidentally came across the answer to my problem. The solution is to create a custom field called “externalURL” and adding an if statement to my loop. If “externalURL” exists; show the post with a link to that URL Else run the usual post.

    Here is the script:

    <div class="press">
    
    					<!--check to see if this is an external link -->
    						<?php
    						$key = 'externalURL';
    						$themeta = get_post_meta($post->ID, $key, TRUE);
    
    						if($themeta != '') {
    						echo 'this is an external link';
    						?>
    						<a href="<?php echo get_post_meta($post->ID, 'externalURL', true); ?>" title="<?php the_title(); ?>">
    						<div id="title"><?php the_title(); ?></div>
    						<?php the_content(''); ?></br>
    						<div id="publishDate"><?php the_time('M Y'); ?></div>	
    
    						</a>
    
    <?php
    						}
    					else{
    ?>
    						<a href="<?php the_permalink(); ?>">
    						<div id="title"><?php the_title(); ?></div>
    						<?php the_content(''); ?></br>
    						<div id="publishDate"><?php the_time('M Y'); ?></div>
    						</a>
    						<?php
    						}
    						?>
    
    </div>

    Thanks to Jeff Star at Perishable press
    http://perishablepress.com/press/2008/12/17/wordpress-custom-fields-tutorial/

    and
    Shelly Cole a.k.a doodlebee of http://brassblogs.com/
    http://wordpress.org/support/topic/302980?replies=2

    who inadvertently gave me the clues I needed to get this done.

Viewing 1 replies (of 1 total)
  • The topic ‘Can I grab the URL link from an uploaded image?’ is closed to new replies.