• I have some problems with the following

    add_shortcode('periodo_affitti', 'translate_rent');
    function translate_rent() {
    global $post;

    $lang = substr( get_locale(), 0, 2 );

    if ('it' != $lang )
    { $period_lang= get_the_author_meta('periodo_affitti_$lang', $post->post_author);
    if ( ! empty( $period_lang)
    return $period_lang ;
    } else {
    return $period_lang;
    }
    } else {
    return $period_lang;
    }
    }, 10, 2 );

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator threadi

    (@threadi)

    What exactly is the question?

    Thread Starter sacconi

    (@sacconi)

    Many questions. I’ll start with:

    1)There is 1 more closing curly braces ‘}’ found, I cant see where..

    2)I wonder if it’s possible to use a “return” in a shortcode

    Moderator threadi

    (@threadi)

    You are missing a ) here:

    if ( ! empty( $period_lang)

    Correct would be:

    if ( ! empty( $period_lang ) )

    And shortcodes must return the output via return. There is no other possibility.

    Thread Starter sacconi

    (@sacconi)

    I think there are more faults with parenthesis…:(

    Thread Starter sacconi

    (@sacconi)

    I had to change ‘periodo_affitti_$lang’ into “periodo_affitti_$lang”

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘multilanguage shortcode’ is closed to new replies.