Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Directory search should match paper tags #85

Open
boonebgorges opened this issue Nov 23, 2015 · 2 comments
Open

Directory search should match paper tags #85

boonebgorges opened this issue Nov 23, 2015 · 2 comments

Comments

@boonebgorges
Copy link
Member

cc @samradd

@r-a-y
Copy link
Member

r-a-y commented Nov 23, 2015

Hmm, I don't think we can add a conditional tax_query clause to WP_Query, can we?

@boonebgorges
Copy link
Member Author

Not really. Clauses of WP_Query are implicitly linked by 'AND'. (Wouldn't it be nice to have WP_Meta_Query etc syntax for WP_Query? Future Release :-D ) As things stand, t'd have to look something like this (maybe in a 'pre_get_posts' callback):

if ( $q->get( 's' ) ) {
    $search_posts = get_posts( array( 's' => $search_terms ) );
    $search_tags = get_posts( array( 'tax_query' => whatever ) );

    $q->set( 's', '' );
    $q->set( 'post__in', array_merge( $search_posts, $search_tags ) );
}

Pretty lousy, and it doesn't do any weighting, but I think it's the only reliable way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants