Inside the build_sql_query() function.
Sandwiched between the ‘Add status declaration’ block and the ‘Build sorting clause’ block.
// ---------------------------------------------- // Limit by custom weblog field // ---------------------------------------------- if ($custom_field = $TMPL->fetch_param('custom_field')) { $custom_field_array= explode('|',$custom_field); if ($custom_field_name = $custom_field_array['1'] AND $custom_field_value = $custom_field_array['0']) { if (isset($this->cfields[$custom_field_value])) { $custom_field_id = $this->cfields[$custom_field_value]; } $sql .= "AND exp_weblog_data.field_id_".$custom_field_id." = '".$custom_field_name."' "; } }
You use it by passing string that looks like this:
custom_field_name|value
In the weblog tag parameter: custom_field
{exp:weblog:entries weblog="blog" custom_field="custom_field_name|value"}
Replace ‘custom_field_name’ with the name of the custom field your evaluating for. And replace ‘value’ with the value that the field needs to contain in order to fetch the relevant entries.
Hack at your own risk. No warranties, quarantees, or doggie fleas.
(code written by Solspace / http://www.pmachine.com/forums/viewthread/29199/)