{"id":1948802,"date":"2020-12-22T05:29:01","date_gmt":"2020-12-22T10:29:01","guid":{"rendered":"https:\/\/theeventscalendar.com\/knowledgebase\/?post_type=tribe-knowledgebase&#038;p=1948802"},"modified":"2026-04-14T12:32:35","modified_gmt":"2026-04-14T16:32:35","slug":"exclude-event-content-from-search","status":"publish","type":"post","link":"https:\/\/theeventscalendar.com\/knowledgebase\/exclude-event-content-from-search\/","title":{"rendered":"Exclude Event\u00a0Content\u00a0From Events Search"},"content":{"rendered":"\n<p>It is easy to search through events via the event search bar on top of every calendar page. By default the search will look for the given string within the event title, the description, and the excerpt.<\/p>\n\n\n\n<p>If you would like to adjust this search functionality so that the search only happens in event titles, then the following snippet can be of help, which will exclude both the content and the excerpt from the search. Place it in your (child) theme&#8217;s <em>functions.php<\/em> file or follow our guide on <a href=\"https:\/\/theeventscalendar.com\/knowledgebase\/k\/best-practices-for-implementing-custom-code-snippets\/\">Best Practices for Implementing Custom Code Snippets<\/a>.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: php; title: ; notranslate\" title=\"\">\nfunction tec_search_only_event_title( $search, WP_Query $wp_query ) {\n\t\/\/ Bail when no search term\n\tif ( empty( $search ) ) {\n\t\treturn $search;\n\t}\n\n\t\/\/ Bail when not searching events\n\tif ( $wp_query-&gt;get( &#039;post_type&#039; ) !== &#039;tribe_events&#039; ) {\n\t\treturn $search;\n\t}\n\n\tglobal $wpdb;\n\t$new_search = preg_replace( &quot;\/{$wpdb-&gt;posts}.post_(content|excerpt) LIKE (&#039;&#x5B;{}a-zA-Z0-9]+&#039;)\/&quot;, &quot;0&quot;, $search );\n\n\treturn $new_search;\n}\n\nadd_action( &#039;posts_search&#039;, &#039;tec_search_only_event_title&#039;, 10, 2 );\n<\/pre><\/div>\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It is easy to search through events via the event search bar on top of every calendar page. By default the search will look for the given string within the event title, the description, and the excerpt. If you would like to adjust this search functionality so that the search only happens in event titles,&#8230;<\/p>\n","protected":false},"author":3,"featured_media":1955565,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","_swpsp_post_exclude":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"ep_exclude_from_search":false,"footnotes":""},"categories":[24,59],"tags":[20,58],"stellar-product-taxonomy":[161],"class_list":["post-1948802","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizing","category-php-function-snippets","tag-code","tag-php","stellar-product-taxonomy-the-events-calendar"],"acf":[],"taxonomy_info":{"category":[{"value":24,"label":"Customizations"},{"value":59,"label":"PHP Functions &amp; Snippets"}],"post_tag":[{"value":20,"label":"Code"},{"value":58,"label":"PHP"}],"stellar-product-taxonomy":[{"value":161,"label":"The Events Calendar"}]},"featured_image_src_large":["https:\/\/images.theeventscalendar.com\/kb\/uploads\/2023\/02\/social-share-1024x538.png",1024,538,true],"author_info":{"display_name":"Jaime Marchwinski","author_link":"https:\/\/theeventscalendar.com\/knowledgebase\/author\/jaimetri-be\/"},"comment_info":0,"category_info":[{"term_id":24,"name":"Customizations","slug":"customizing","term_group":0,"term_taxonomy_id":24,"taxonomy":"category","description":"","parent":0,"count":49,"filter":"raw","term_order":"0","cat_ID":24,"category_count":49,"category_description":"","cat_name":"Customizations","category_nicename":"customizing","category_parent":0},{"term_id":59,"name":"PHP Functions &amp; Snippets","slug":"php-function-snippets","term_group":0,"term_taxonomy_id":59,"taxonomy":"category","description":"","parent":24,"count":38,"filter":"raw","term_order":"0","cat_ID":59,"category_count":38,"category_description":"","cat_name":"PHP Functions &amp; Snippets","category_nicename":"php-function-snippets","category_parent":24}],"tag_info":[{"term_id":20,"name":"Code","slug":"code","term_group":0,"term_taxonomy_id":20,"taxonomy":"post_tag","description":"","parent":0,"count":5,"filter":"raw","term_order":"0"},{"term_id":58,"name":"PHP","slug":"php","term_group":0,"term_taxonomy_id":58,"taxonomy":"post_tag","description":"","parent":20,"count":26,"filter":"raw","term_order":"0"}],"_links":{"self":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1948802","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=1948802"}],"version-history":[{"count":3,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1948802\/revisions"}],"predecessor-version":[{"id":1968995,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/1948802\/revisions\/1968995"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media\/1955565"}],"wp:attachment":[{"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=1948802"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=1948802"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=1948802"},{"taxonomy":"stellar-product-taxonomy","embeddable":true,"href":"https:\/\/theeventscalendar.com\/knowledgebase\/wp-json\/wp\/v2\/stellar-product-taxonomy?post=1948802"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}