Create citation and url in post using 3 custom fields with conditions for each field… So close!

I’m not sure if I’m meeting all of your requirements here, but I think this might work.

<div class="source">
<?php

$name = get_post_meta($post->ID, 'sourcename', true);
$url = get_post_meta($post->ID, 'sourceurl', true);
$title = get_post_meta($post->ID, 'sourcetitle', true);

$snippet = str_replace( "http://", "", $url );
$snippet = substr( $snippet, 0, 22 ) . "...";

if ( !empty( $title ) && !empty( $name ) && !empty( $url ) )
    $output="<h3 class="cite"><a href="" . $url . '">' . $title . '</a> | ' . $name . '</h3>';
else if ( !empty( $name ) && !empty( $url ) )
    $output="<h3 class="cite"><a href="" . $url . '">' . $name .  '</a></h3>';
else if ( !empty( $title ) && !empty( $url ) )
    $output="<h3 class="cite"><a href="" . $url . '">' . $title . '</a></h3>';
else if ( !empty( $title ) && !empty( $name ) )
    $output="<h3 class="cite">" . $title . ' | ' . $name . '</h3>';
else if ( !empty( $title ) )
    $output="<h3 class="cite">" . $title . '</h3>';
else if ( !empty( $name ) )
    $output="<h3 class="cite">" . $name . '</h3>';
else if ( !empty( $url ) )
    $output="<h3 class="cite"><a href="" . $url . '">' . $snippet . '</a></h3>';
else
    $output="";

echo $output;

?>
</div>

Let me know if it doesn’t!