在创世体框架中有条件地显示自定义元字段

时间:2016-07-06 21:30:09

标签: php wordpress if-statement echo genesis

我正在尝试仅在有数据显示时才在自定义元字段中显示我的网页数据。这就是我现在所拥有的。

我尝试了以下代码,但echo语句失败:标签' State'不会显示' genesis_custom_field(' state')'的字段数据。出现了。

audio: Failed to create voice `goldfish_audio_in'
qemu-system-i386.exe: warning: opening audio input failed

1 个答案:

答案 0 :(得分:0)

尝试这种方式:

    var data = Backbone.Syphon.serialize($(e.currentTarget).closest('form.my_form')[0]));   
    this.model.set(data);

    if(this.model.isValid(true)) {

                   data['metas'] = this.context.metaData;
                   data['metas'][0]['locale'] = this.parentObj.model.get('locale');

                   data['metas'][0]['name'] = data['name'];
                   delete data['name'];
                 }

                 var tempDynAttrs = [];
                 if(data['dynamicAttributes']){
                       $.each(data['dynamicAttributes'], function(index,obj) {
                           if(obj['attributeValue'] !== null && obj['attributeValue'] !== undefined ) {
                               tempDynAttrs.push({
                                    attributeName: obj['attributeName'],
                                    attributeValue: [obj['attributeValue']],
                                    locale: data['defaultLocale'],
                                    status: 'active'
                                });
                             } 
                       });
                   }
                 data['dynamicAttributes'] = tempDynAttrs;

                 this.model.save(data, {
                   url: this.model.url(),
                   patch: true,
                   success : function(model, response) {
                       $('#headerMessage').html('Data is updated successfully');
                   },
                   error : function(model, response) {
                        $('#headerMessage').html('Error updating data');
                   }
               });
} else {
    $('#formPanel').animate({
                 scrollTop: $('.has-error').first().offset().top-50
               }, 100);
     return false;
}