Title: Conditional Tag in Code Snippets
Last modified: October 11, 2021

---

# Conditional Tag in Code Snippets

 *  Resolved [airbarney](https://wordpress.org/support/users/airbarney/)
 * (@airbarney)
 * [4 years, 8 months ago](https://wordpress.org/support/topic/conditional-tag-in-code-snippets/)
 * I’m trying to get this code to execute only on the home page. This is the working
   code without the conditional tag.
 * function remove_beds_field($vars)
    { return; } add_filter(‘ridx_search_form_field_beds’,‘
   remove_beds_field’);
 * This is my effort at getting the conditional tag to work.
 * function remove_beds_field($vars)
    { if ( is_front_page () ) { return; } } add_filter(‘
   ridx_search_form_field_beds’, ‘remove_beds_field’);

Viewing 1 replies (of 1 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-tag-in-code-snippets/#post-15083481)
 * Hi [@airbarney](https://wordpress.org/support/users/airbarney/),
 * You’re very close. The key is to only return an empty result if this `is` the
   front page, and otherwise return the unchanged `$vars`:
 *     ```
       add_filter( 'ridx_search_form_field_beds', function ( $vars ) {
       	if ( is_front_page() ) {
       		return;
       	}
   
       	return $vars;
       } );
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Conditional Tag in Code Snippets’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/conditional-tag-in-code-snippets/#post-15083481)
 * Status: resolved