Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter kevinblend

    (@kevinblend)

    Ended up solving it on my own – as it turns out custom post types are not searchable by default in wordpress so I modified the search function in the functions file. For anyone trying to figure this out, paste this into ‘functions.php’:

    add_filter( 'pre_get_posts', 'tgm_io_cpt_search' );
    /**
     * 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 original query.
     * @return object $query The amended query.
     */
    function tgm_io_cpt_search( $query ) {
    
        if ( $query->is_search ) {
    	$query->set( 'post_type', array( 'post', 'event' ) );
        }
    
        return $query;
    
    }
Viewing 1 replies (of 1 total)