Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

wp search post type results page

01
02
03
04
05
06
07
08
09
10
11
12
/**
 * This function modifies the main WordPress query to include an array of 
 * post types instead of the default 'post' post type.
 *
 * @param object $query The main WordPress query.
 */
function tg_include_custom_post_types_in_search_results( $query ) {
    if ( $query->is_main_query() && $query->is_search() && ! is_admin() ) {
        $query->set( 'post_type', array( 'post', 'movies', 'products', 'portfolio' ) );
    }
}
add_action( 'pre_get_posts', 'tg_include_custom_post_types_in_search_results' );
Comment

PREVIOUS NEXT
Code Example
Typescript :: pass class to generic typescript 
Typescript :: check if column exists in dataframe python 
Typescript :: add if not exists lodash object list 
Typescript :: accessing list elements in dictionary python 
Typescript :: make foreign key sql in exists row 
Typescript :: provider in ethers.js 
Typescript :: how to clear known_hosts in ssh 
Typescript :: select constraints in sql 
Typescript :: typescript final example 
Typescript :: define typescript types 
Typescript :: boto3 Requests specifying Server Side Encryption with AWS KMS managed keys require AWS Signature Version 4 
Typescript :: typescript convert readonly 
Typescript :: listobjects vba 
Typescript :: comments visual studio code html 
Typescript :: typescript http get attach headers 
Typescript :: avatar image mui not centered 
Typescript :: watch ref.current changes typescript 
Typescript :: The following TestContainer was not found 
Typescript :: remove showing results woocommerce shortcode 
Typescript :: build with tsconfig-paths 
Typescript :: typescript variable 
Typescript :: onSubmit for form in antd 
Typescript :: literal types typescript 
Typescript :: Why do we use fragments in react? 
Typescript :: typescript to java converter 
Typescript :: Request exceeded the limit of 10 internal redirects due to probable configuration error 
Typescript :: nullish coalescing typescript 
Typescript :: typescript 
Typescript :: typeorm generated 
Typescript :: curl -s "http://google.com?[1-1000]" 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =