Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter romeovs

    (@romeovs)

    Ok thanks! very nice indeed that extra parameter ‘lang’

    Thread Starter romeovs

    (@romeovs)

    Yes well actually.

    My client wants me to build a homepage were the location of certain pages is fixed.
    So I need to get pages by slug.

    I hoped I could just give the slug in english and then check if there are translations available.

    $post = get_posts(array(
       'name' => $slug,
       'post_type' => 'any'
    ))[0];
    $id = $post->ID;
    $id = get_translation(cml_get_current_language()->cml_language_slug, $id);

    This doesn’t work however because the slugs are different for each language and somehow get_posts only returns a post if it is found to be in the current language.

    is there a way around this (eg use get_posts to find all posts in any language, or translate the slug automatically)?

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