I am trying to get only the source language posts on a secondary language page
I have been trying to use
do_action( 'wpml_switch_language', string 'en' );
$sitepress->switch_lang('en');
change the 'suppress_filters' option in get_posts args (This gives me all languages, but I want only source i.e english).
I basically want to make a shortcode that get's all english posts and counts them and displays the number. But I need to be able to get the English posts no matter what language is currently set on the page.
before your ticket is assigned to one of my colleagues, please allow me to walk you through some initial debugging steps. This will help speed up the support process.
You code seems not correct to me.
You can query the posts in the original language and get the ID( with WordPress Hooks ) , then you can use this hook :
And feed it with the ID you got from the previous step and the above hook will return the IDs from a specific language.
Use it in a loop and you can get the number you wish.
Wrap the whole function into a shortcode and use it with whatever you ish.
Have in mind that giving support is out of the scope of this forum but the hints I have shared are a very good starting point in order to build whatever you wish.
If you are not able to accomplish this, you could also try to hire a WPML contractor (https://wpml.org/contractors/)