插入自定义字段时WordPress RSS损坏

时间:2018-11-29 19:12:42

标签: wordpress rss custom-fields

我在WordPress feed中包含了自定义字段。但是,这会使提要无效。

进纸验证链接: http://www.feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.apnijobs.pk%2Ffeed

用于将自定义字段插入RSS的代码:

add_action('rss2_item', 'add_my_custom_field_node');

function add_my_custom_field_node() {
  global $post;
  $custom_fields = get_post_custom();

  $location = $custom_fields["location"][0];
  if(!empty($location)){ ?> 
    <location><?php echo $location;?></location> 
  <?php }

  $employer = $custom_fields["employer"][0];
  if(!empty($employer)){?> 
   <employer><?php echo htmlentities($employer);?></employer> 
 <?php }

 $salary = $custom_fields["salary"][0];
  if(!empty($salary)){?> 
  <salary><?php echo $salary; ?></salary> 
 <?php }
}

0 个答案:

没有答案