• Resolved bluebird2

    (@bluebird2)


    Some of my posts are translations from some other sources, and some are not. I need to add a new field after author’s name. The field is “Translated by:” or “Translator:”.
    It should appear when there is a translator added to a post, and stay hidden when the post is not translated.

    How can I add this new field to my posts and pages?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter bluebird2

    (@bluebird2)

    I used custom field to add “translator” to certain posts. Then I added this piece of code to the “single.php”. The solution works fine on posts that have a translator:

    Translated by: <?php echo get_post_meta($post->ID, 'translator',true); ?>

    The problem is the words “Translated by:” show up on every post, instead of showing up only on the posts that have a “translator” custom field.

    Any solution?

    Thread Starter bluebird2

    (@bluebird2)

    Anybody here?

    Thread Starter bluebird2

    (@bluebird2)

    Anybody here?

    It would be simpler just to list the translator along with your other custom fields (if you have any) by placing the call <?php the_meta() ?> where you want it to appear. Then if your Key for the custom field is “Translated by:” and the Value is the translator’s name, the credit will only appear on posts that have that custom field attached.

    HTH.

    Thread Starter bluebird2

    (@bluebird2)

    I have several custom fields. How can it know it should show the value for the key “Traslator”?

    Oh, you could just try something like:

    <?php
    $translator = get_post_meta($post->ID, ‘translator’, true);
    if ( $translator ) {
    echo “Translated by: $translator”;
    }
    ?>

    Thread Starter bluebird2

    (@bluebird2)

    Thank you. That works perfectly!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘A “Translated by” Field’ is closed to new replies.