• I am running another script which connects to twitter on my site. I am trying to use a custom field to insert the FRIENDS_USERNAME.

    My custom field is called “twittername” I usually use the following code to include custom fields in HTML

    $key="twittername"; echo get_post_meta($post->ID, $key, true);

    But I don’t know how to include in php. Can someone please take a glance at my code below and see where I might be going wrong?

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    <?php
         //username and password to pass to twitter -
         $username = 'xxxxx';  //these dont have to be in caps
         $password = 'xxxxx';
    
         //$twitterUser = 'YOUR_FRIENDS_USERNAME';
         $twitterUser = '$key="twittername"; echo get_post_meta($post->ID, $key, true);';
    ?>
    <?php endwhile; else: ?>
    <?php endif; ?>

    I’d appreciate any help! I am not good with php!

    Thanks,

    Jon

Viewing 1 replies (of 1 total)
  • Not too sure exactly your goal with

    $twitterUser = '$key="twittername"; echo get_post_meta($post->ID, $key, true);';

    but this would assign the value of that custom field to a variable:

    $twitterName = get_post_meta($post->ID, 'twittername', true);

Viewing 1 replies (of 1 total)
  • The topic ‘Help with Custom Fields’ is closed to new replies.