• Resolved Julien

    (@emael76)


    Hello there,

    I have a request for one of my client. I had to code a plugin that allows him to chose any post (including CPTs) from gutenberg inside a custom block. He now asks me if it would be possible to use polylang to filter the list of posts based on its language. I can’t seem to find anything when I log my getEntityRecords about language (except the slug that I could parse but it’s not great…).

    My question is : is it possible to get language listed inside getEntityRecords with the pro version ? Also is it possible to get the language of the page in which the user is loading my custom block ?

    I’d like to have something like this :

    
    	const posts = useSelect<Post[] | null>(select =>
    		select("core").getEntityRecords("postType", post_type, {
    			per_page: 99,
    			language: "fr",
    		})
    	);
Viewing 1 replies (of 1 total)
  • Thread Starter Julien

    (@emael76)

    Just found out that you need PRO for this.
    Basically buy the PRO version then you can call getEntityRecoards and get language :

    const posts = useSelect<Post[] | null>(select =>
    		select("core").getEntityRecords("postType", post_type, {
    			per_page: 99,
    			lang: selectedLanguage,
    		})
    	);
Viewing 1 replies (of 1 total)

The topic ‘API language selection’ is closed to new replies.