Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joshuadavidnelson/33e1948e08fdc42f758ed3b8c083c639 to your computer and use it in GitHub Desktop.

Select an option

Save joshuadavidnelson/33e1948e08fdc42f758ed3b8c083c639 to your computer and use it in GitHub Desktop.

Revisions

  1. joshuadavidnelson revised this gist Aug 9, 2022. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions multilingualpress-cross-post-type.php
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,4 @@
    // Cross-post-type connections.
    add_filter( 'multilingualpress.remote_post_search_arguments', 'jdn_remote_post_search_arguments', 100, 1 );

    <?php
    /**
    * Filter the post search arguments allow for cross-post-type connections.
    *
    @@ -19,4 +17,6 @@ function remote_post_search_arguments( $args ) {
    }

    return $args;
    }
    }

    add_filter( 'multilingualpress.remote_post_search_arguments', 'jdn_remote_post_search_arguments', 100, 1 );
  2. joshuadavidnelson created this gist Aug 9, 2022.
    22 changes: 22 additions & 0 deletions multilingualpress-cross-post-type.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    // Cross-post-type connections.
    add_filter( 'multilingualpress.remote_post_search_arguments', 'jdn_remote_post_search_arguments', 100, 1 );

    /**
    * 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;
    }