• I’m using a theme from Templatic.com called Real Estate 2. Overall the theme is great but I’m running a problem that the developer doesn’t have a solution for.

    There is a custom field that is built-in which allows the specific post_type (in this case a property listing) to select a bedroom count. However, 0 (Zero, as in Studio/bachelor pad) is not an included option. The developer said the reason the number ZERO couldn’t be included is because it’s not a numerical value. Below is the area in the custom_function.php file that the developer said he tried to make edits to but couldn’t get it to work.

    Can anyone see based on the code below where I can make a change so I can add 0 as an option?

    Thanks for any help.

    <?php
    }
    function get_max_number_bedrooms()
    {
    	$generalinfo = get_option('mysite_general_settings');
    	if($generalinfo['max_bedrooms'])
    	{
    		return $generalinfo['max_bedrooms'];
    	}else
    	{
    		return 10;
    	}
    }
    function get_bedroom_dl($proprty_bedroom)
    {
    	$i=1;
    	$max_bedrooms = get_option('ptthemes_bedrooms');
    	for($i=1;$i<=$max_bedrooms;$i++)
    	{
    		$addval = '';
    		echo '<option ';
    		if($i==$proprty_bedroom)
    		{
    			echo 'selected="selected"';
    		}
    		if($i==$max_bedrooms)
    		{
    			$addval = "+";
    		}
    		echo ' value="'.$i.$addval.'">'.$i.$addval.'</option>';
    	}
    }
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The loop counter $i would have to be initialised to 0 for starters.

    There could be type cast issues in the comparison with $proprty_bedroom (sic, be careful with this odd spelling), using == should mean type doesn’t matter, but this doesn’t always work as expected. You may need to experiment with explicit type casting and possibly using === comparison. This is only a problem if the option list shows the 0 option, but it is not preselected when it should be.

Viewing 1 replies (of 1 total)

The topic ‘Can't Select '0' As a Numeric Option’ is closed to new replies.