Skip to content

Commit

Permalink
Fix API not working for post types with exclude_from_search = true.
Browse files Browse the repository at this point in the history
  • Loading branch information
anhdoanmis committed Jul 14, 2021
1 parent 8391ecf commit e48e193
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion inc/query/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public function parse_query( WP_Query $query ) {

$post_type = $query->get( 'post_type' );
if ( ! $post_type ) {
$query->set( 'post_type', 'any' );
$relationship = MB_Relationships_API::get_relationship( $args['id'] );
$target = 'from' === $args['direction'] ? 'to' : 'from';
$post_type = isset( $relationship->$target['field']['post_type'] )
? $relationship->$target['field']['post_type']
: 'any';
$query->set( 'post_type', $post_type );
}
$query->set( 'suppress_filters', false );
$query->set( 'ignore_sticky_posts', true );
Expand Down
2 changes: 1 addition & 1 deletion inc/query/term.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function query( $args, $query_vars, $relationship ) {
$query_vars = wp_parse_args(
$query_vars,
array(
'taxonomy' => $settings['taxonomy'],
'taxonomy' => $settings['field']['taxonomy'],
'hide_empty' => false,
)
);
Expand Down

0 comments on commit e48e193

Please sign in to comment.