我在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 }
}