Skip to content

Instantly share code, notes, and snippets.

@joshuadavidnelson
Last active August 9, 2022 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuadavidnelson/33e1948e08fdc42f758ed3b8c083c639 to your computer and use it in GitHub Desktop.
Save joshuadavidnelson/33e1948e08fdc42f758ed3b8c083c639 to your computer and use it in GitHub Desktop.
Filter the MultilingualPess admin metabox to allow for connecting translations to other post types on remote site.
<?php
/**
* Filter the post search arguments allow for cross-post-type connections.
*
* @param array $args the WP_Query arguments used.
* @return array
*/
function remote_post_search_arguments( $args ) {
$translated_post_types = array( 'post', 'page', 'product' );
if ( isset( $args['post_type'] )
&& is_string( $args['post_type'] )
&& in_array( $args['post_type'], $translated_post_types, true ) ) {
$args['post_type'] = $translated_post_types;
}
return $args;
}
add_filter( 'multilingualpress.remote_post_search_arguments', 'jdn_remote_post_search_arguments', 100, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment