• Resolved DjoleNS

    (@djolens)


    Hello,

    I need your assistance with custom post types and queries. My theme is using few custom post types (Work, Team…). I was able to translate them manually entering URL /wp-admin/post-new.php?post_type=work&from_post=nnn&new_lang=en

    However, custom post types are displayed on pages with specific template. For example “Work” page will display only “Work” custom posts.

    My question: is there any way to limit query to display language specific posts on page with specific template? For example, “Work” page in German language to display only “Work” posts created in German?

    Thank you.

    https://www.ads-software.com/plugins/polylang/

Viewing 2 replies - 1 through 2 (of 2 total)
  • You can specify the language in the query like this:

    $query = new WP_Query(array(
    ‘post_type’ => ‘work’,
    ‘lang’ => ‘en’
    ));

    Obviously switch the language slug for the one you need. Polylang should only be returning results in the current site language though. The lang parameter should be used for getting posts from a language different from the current site language.

    Thread Starter DjoleNS

    (@djolens)

    Hi Brian,

    Thank you for your help! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Custom post type and queries’ is closed to new replies.