[wp-meta] [Making WordPress.org] #1671: Restrict searches by site section
Making WordPress.org
noreply at wordpress.org
Thu May 5 12:06:09 UTC 2016
#1671: Restrict searches by site section
-------------------------------------+--------------------------
Reporter: keesiemeijer | Owner: coffee2code
Type: enhancement | Status: accepted
Priority: normal | Milestone:
Component: developer.wordpress.org | Resolution:
Keywords: has-patch |
-------------------------------------+--------------------------
Comment (by keesiemeijer):
I don't think the handbook plugin should interfere with queries more
[https://meta.trac.wordpress.org/browser/sites/trunk/wordpress.org/public_html
/wp-content/plugins/handbook/handbook.php#L210 than it already does].
Queries should be theme territory as they all have different needs.
I've created a ticket #1693 to make it easier for themes to do (search)
queries themselves.
As an example for this theme using the functions for search queries we
could di something like this
{{{#!php
function pre_get_posts( $query ) {
if ( !( !is_admin() && $query->is_main_query() &&
$query->is_search() ) ) {
return;
}
if( wporg_is_handbook() ) {
// Search only in current handbook post type.
// just to make sure. post type should already be
set
$query->set( 'post_type',
wporg_get_current_handbook() );
} else {
// Search parsed post types instead of all post
types.
$query->set( 'post_type',
DevHub\get_parsed_post_types() );
}
}
}}}
--
Ticket URL: <https://meta.trac.wordpress.org/ticket/1671#comment:4>
Making WordPress.org <https://meta.trac.wordpress.org/>
Making WordPress.org
More information about the wp-meta
mailing list