Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Yes, you can use something like that:

    $temp = array();
    $post = new MslsOptionsPost( $id );
    foreach ( $post->get_arr() as $language => $post_id ) {
        if ( $post->has_value( $language ) )
            $temp[$language] = $post->get_postlink( $language );
    }

    $temp is your array. It works for posts and pages.

    Cheers,
    Dennis.

    Thread Starter titi5895

    (@titi5895)

    Hi Dennis,

    Thanks for your answers.

    I tried you code but nothing happened, $temp stays empty.

    Have you any idea what’s wrong?

    Thank you for your help

    Thread Starter titi5895

    (@titi5895)

    [Edit] For posts $temp stays empty but for pages $temp contains the current url (in every lines)

    Plugin Author Dennis Ploetner

    (@realloc)

    Strange. Do you checked that the post with this ID has translations?

    Thread Starter titi5895

    (@titi5895)

    I found the error my function that returns the post id was wrong.

    $temp is no longer empty but for all languages it contains the current url

    [de_DE] => https://de.site.com/post/
    [en_GB] => https://de.site.com/post/
    [es_ES] => https://de.site.com/post/
    [fi] => https://de.site.com/post/
    [fr_FR] => https://de.site.com/post/
    [it_IT] => https://de.site.com/post/
    [pt_PT] => https://de.site.com/post/

    Plugin Author Dennis Ploetner

    (@realloc)

    Yes, that’s my fault. Try this one:

    $temp  = array();
    $blogs = MslsBlogCollection::instance();
    $post  = new MslsOptionsPost( $id );
    foreach ( $blogs->get_filtered() as $blog ) {
    	if ( $blog->userblog_id != $blogs->get_current_blog_id() ) {
    		$language = $blog->get_language();
    		switch_to_blog( $blog->userblog_id );
    		$temp[$language] = $post->get_permalink( $language );
    		restore_current_blog();
    	}
    }
    Thread Starter titi5895

    (@titi5895)

    This code works very well !

    Thanks a lot Dennis

    Plugin Author Dennis Ploetner

    (@realloc)

    You’re welcome!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Get page/post translations’ is closed to new replies.