这是我为自定义帖子类型创建的模板文件代码。
if( isset( $_GET['req_edit'] ) && is_numeric( $_GET['req_edit'] ) ){
--some code---
}else{
--some code---
}
如果还有大量的代码,但我只发布了那么多。因为当我评论其他条件它没关系,但当我不评论其他然后它在插件文件中创建致命错误。这是错误。
Fatal error: Call to a member function get_results() on a non-object in
/home6/plotsup1/public_html/plotsup_plot/wp
-content/plugins/revslider/inc_php/framework/db.class.php on line 125
这背后可能的原因是什么? 这是我在其他地方的代码
else {
$action = 'view';
$submit_title = '';
$submit_description = '';
$prop_category = '';
$property_address = '';
$property_county = '';
$property_state = '';
$property_zip = '';
$country_selected = '';
$property_status = '';
$property_price = '';
$property_label = '';
$property_size = '';
$property_lot_size = '';
$property_rooms = '';
$property_bedrooms = '';
$property_bathrooms = '';
$option_video = '';
$option_slider = '';
$video_type = '';
$embed_video_id = '';
$property_latitude = '';
$property_longitude = '';
$google_view = '';
$prop_featured = '';
$google_camera_angle = '';
$prop_category = '';
$wpdb = '';
$firm_name = '';
$prop_stat = '';
$monthly_rent = '';
$maintainance = '';
$owner_ratio = '';
$developer_ratio = '';
$deposit = '';
$property_status = '';
$state = '';
$district = '';
$taluka = '';
$landmark = '';
$req_frontage = '';
$property_deal = '';
$req_reason = '';
$docid = '';
$req_ownership = '';
$nakashaid = '';
$property_rate = '';
$land_area_from = '';
$land_area_to = '';
$req_document = '';
$req_location = '';
$req_distance = '';
$budget_from = '';
$budget_to = '';
$purchase = '';
$req_access = '';
$req_facing = '';
$electricity = '';
$water = '';
$drainage = '';
$boundry = '';
$edit_id='';
$custom_fields = get_option( 'wp_estate_custom_fields', true);
$custom_fields_array=array();
$i=0;
if( !empty($custom_fields) ){
while($i< count($custom_fields) ){
$name = $custom_fields[$i][0];
$type = $custom_fields[$i][2];
$slug = str_replace(' ','_',$name);
$custom_fields_array[$slug]='';
$i++;
}
}
foreach ($status_values_array as $key=>$value) {
$value = trim($value);
$value_wpml=$value;
$slug_status=sanitize_title($value);
if (function_exists('icl_translate') ){
$value_wpml=
icl_translate('wpestate','wp_estate_property_status_front_'.$slug_status,$value );
}
$property_status.='<option value="' . $value . '"';
if ($value == $prop_stat) {
$property_status.='selected="selected"';
}
$property_status.='>' . $value_wpml . '</option>';
}
$video_values = array('vimeo', 'youtube');
foreach ($video_values as $value) {
$option_video.='<option value="' . $value . '"';
$option_video.='>' . $value . '</option>';
}
$option_slider='';
$slider_values = array('full top slider', 'small slider');
$slider_type = get_post_meta($edit_id, 'prop_slider_type', true);
foreach ($slider_values as $value) {
$label_slider=$value;
$slug_slider=sanitize_title($value);
if(function_exists('icl_translate')){
$label_slider= icl_translate('wpestate','wp_estate_property_slider'.$slug_slider,
$value );
}
$option_slider.='<option value="' . $value . '"';
if ($value == $slider_type) {
$option_slider.='selected="selected"';
}
$option_slider.='>' . $label_slider . '</option>';
}
}
答案 0 :(得分:2)
错误是由于声明不当引起的。您必须将$wpdb
变量声明为全局变量。即:
global $wpdb;
同样,如果还有其他变量需要声明,你必须这样做。