• Hi,

    I have multiple custom fields named Awards in the following format http://somelink.com/image.jpg&http://somelink.com. I use the below code to create a little gallery. I would like to use the <span class='delete'><a href=".'#'." title='Delete!' />[x]</span> to delete each individual image. I m not sure how to do this. Can anybody help?

    <?php $awds = get_post_meta($post->ID, "Awards", false); ?>
    
    			<?php foreach($awds as $awd) {
    
    				  $tawd = explode("&", "$awd");
    				  $tawdd = $tawd[0];
    				  $tawddd = $tawd[1];
    
    				  echo '<a href="'.$tawdd.'">'.'<img width="200" src="'.$tawddd.'" alt="alt"/>'.'</a>';
    				  echo "<span class='delete'><a href=".'#'." title='Delete!' />[x]</span>";
    			?>
    
    		<?php } ?>
Viewing 1 replies (of 1 total)
  • Thread Starter cip6791

    (@cip6791)

    I created a new page

    <?php
    /*
    Template Name: Delimg
    */
    ?>
    
    <?php
    
    if($_GET['id'] != ""){
    
    $img = $_GET['id'];
    
    echo $img;
    
    delete_post_meta(?, 'Awards', '?');
    
    }  
    
    ?>

    and modified the delete link.

    echo "<span class='delete'>" . "<a href='http://mysite.com/delimg?id=".$tawdd."'>[x]</a>" . "</span>";

    But I’m still not sure how to get the right custom field.

Viewing 1 replies (of 1 total)
  • The topic ‘Delete custom field’ is closed to new replies.