To use get_adjacent_post you have exclude all the term id of that specific taxonomy, For polylang your texonomy is language, First you have retrieve all term ids of indivual languages, and then exclude all of them other than the one you want.
global $post;
$post_id = [XXXX]; // any specific post id
$post = get_post($post_id);
//get all the tems of language taxonomy
$terms = get_terms( 'language', array(
'hide_empty' => false,
) );
$excludeds_term_ids = array();
foreach($terms as $term){
if($term->slug !='en'){ // exlude all of them other than 'en'
$excludeds_term_ids[]= $term->term_id;
}
}
$next_post = get_adjacent_post(true,$excludeds_term_ids,false,'language');
echo $next_post->ID;
Related Posts:
- How do I check if I linked to a post before I delete it?
- How to use “Add link” pop up for a WordPress widget
- Different post sort order within different categories
- Displaying the category name of a custom post type
- Elegant way to include only published posts with get_objects_in_term()?
- Portable Post Links
- Show WordPress Custom Taxonomy Items Based On a Selected Item From Another Custom Taxonomy
- WordPress: How to get the current logged in author page URL?
- How are terms connected with posts in database?
- Convert IPTC keywords to blog post tags
- Is it possible to add a first and latest posts link?
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Importing data from spreadsheet into wordpress DB, along with custom taxonomies and their terms
- Get current users post URL?
- Navigation link to specific user page
- how to grab first link in post… and of course call it
- Load post content into div with ajax
- wp_list_categories link to first post of category instead of calling taxonomy template
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- Linking to page with all posts
- deleting terms programmatically
- Adding Multiple Values to a Post Meta Key
- How do I get the slug of a custom taxonomy category of a post?
- Post taxonomy from exif data
- Using Custom Posts with Metaboxes and Drop-downs
- Does an action fire when adding a tag via the “Tags” meta box?
- How can I add a meta-box to the posts editor containing all items of a custom taxonomy as checkbox?
- disable column on post and user list
- Adding a text link under the post title in the lists of posts
- if I create ‘front-page.php’, then how do I link to post index?
- Direct link to “New post” in specific category?
- Get posts by name and taxonomy term
- Set terms in a custom post
- How should I add links to other pages/posts from my post?
- Pass data between pages
- Choose whether to automatically add a taxonomy with the same name as the post
- How to bulk-untag multiple posts?
- Force the “Choose from the most used tags” meta box section to always be expanded
- Custom loop pagination links not working
- Posts list in custom taxonomy
- How to Restrict Previous & Next Post Link to Posts of Same Category?
- Get Posts Under Custom Taxonomy
- Prepending %category% onto default posts fails
- How to handle broken links created by permalink/slug changes?
- Remove Custom Post Type Slug and add Custom Taxonomy to Permalink Structure?
- How can I setup a relationship using categories in WordPress?
- How to display posts via custom taxonomy terms using checkboxes?
- How can I hide tags on a child-category page, if that tag has not been used?
- 404 error on default post type and default taxonomy fronted page
- How do I insert a post with custom post type and relate it to a custom taxonomy?
- outputting posts’ taxonomies: cant get ‘get_the_taxonomies’ working
- Loop parent terms {display posts} AND loop child terms {display posts}
- How to add a class to edit_post_link?
- Is there a query string for edit.php to show all posts that have no custom taxonomy terms?
- Adding a user’s ID behind the tag ref link address
- All Posts Linking to Author Posts directly
- How to make Link to go on the first post
- Link to date_query results in WordPress
- Authors’ Links on Homepage Not Going to Author Post Pages
- Short link to read complete post
- Delete all Tag Links from Posts
- How to link post titles on page A to its posts on page B?
- How to create several Post pages
- How To Use Custom Tax of a Post Type
- Geting error in post and category [closed]
- How to associate a custom taxonomy to a post multiple times
- How to display the post categories for each post inside the loop with custom format?
- WP query taxonomy optimization
- Remove all external links from posts
- Add data attribute of post_id for Internal links
- Prevent the automatic URL linking added in last update
- Some custom post types did not return an object
- Post not using taxonomy template
- How do I remove all links from all my posts at once?
- Show post count in custom taxonomy page
- Create/Set Category as Title of Post
- Taxonomy checkboxes not showing current status on edit page
- Page with Category Returning 1
- Creating a link to the first post in a category
- Slug collision between page, taxonomy and custom post type
- Customizing URL slugs of Custom Post Type and Taxonomy make posts/pages 404
- Post Category link is same with Page link
- wordpress display posts by terms id or name
- How to get post count including nested categories
- Custom Taxonomy From Database
- Multiple Custom Post Type loop logic
- How to add a class to links inside posts text
- How to display term in archive page?
- How can add posts without category into category
- 404 for some custom taxonomy not ALL taxonomy
- Displaying Results From Custom Taxonomy Query
- Multiple loops on a Search result page?
- How to change link with broken link?
- Modifying the permalink href for posts with jquery
- retrieve post slug by post_tags taxonomy
- Taxonomy Category category.php not working
- After the local installation of an old WP website I can see the homepage but I can’t access to the articles, why?
- Filter/Sort Post Form On Taxonomy page
- I want the Title of page/post to show up topmost when reading the post/page
- How to keep prev/next nav on posts in same taxonomy