0

On the function below, after echo '</span>';, I want to add this a piece of code:

&nbsp;<a href="<?php $key="link"; echo get_post_meta($post->ID, $key, true); ?>" target="_blank">Images Source</a>

But I dunno how to do it, any suggestions on how to do this?

//echo '<div class="pull-left">';
        echo in_array( 'date',$meta_info ) ? sprintf( '<span class="post-meta-info posted-on">' . apply_filters('yt_icon_date_time', '<i class="fa fa-clock-o"></i>') . ' %1$s</span>',
            $time_string
        ) : '';
        if( in_array( 'comments',$meta_info ) ){
            echo '<span class="post-meta-info with-cmt">' . apply_filters('yt_icon_comment', '<i class="fa fa-comments"></i>') . ' ';
                comments_popup_link( __( '0 Comments', 'theme' ), __( '1 Comment', 'theme' ), __( '% Comments', 'theme' ));
            echo '</span>';
        }



    //echo '</div>';
0
if( in_array( 'comments',$meta_info ) ){
            $key="link";
            echo '<span class="post-meta-info with-cmt">' . apply_filters('yt_icon_comment', '<i class="fa fa-comments"></i>') . ' ';
                comments_popup_link( __( '0 Comments', 'theme' ), __( '1 Comment', 'theme' ), __( '% Comments', 'theme' ));
            echo '</span>';
            echo '&nbsp;<a href="'. get_post_meta($post->ID, $key, true) .'" target="_blank">Images Source</a>' . "\n";
        }

Try this code once. I modified the code with your supplied content.

  • what about the code href="<?php $key="link" look like missing on your modified code – user31445 Aug 5 '14 at 4:37
  • no it is not missing. I assigned it at top $key="link"; – Chinmoy Kumar Paul Aug 5 '14 at 4:43
  • ok, didn't see it,but when I added link on custom field with value yahoo.com it doesnt work. the image source show the single post link, instead of value yahoo.com – user31445 Aug 5 '14 at 5:02
  • hmm...if you're using the function for meta value then you'll assign the global $post; inside the function. Then $post->ID will work in get_post_meta function. – Chinmoy Kumar Paul Aug 5 '14 at 5:11
  • so how to add global $post; ? would you mind to explain it ,I am still learning btw, and thanks for the help – user31445 Aug 5 '14 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.