• Resolved airbarney

    (@airbarney)


    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

    (@bungeshea)

    Hi @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.