我已经成功地将自定义元标记添加到我页面上的元框中。我遇到的问题是,当metabox没有数据时,它仍然显示在html中。这是我得到的代码,有人对如何不显示这一点有什么想法吗?
<!-- Google Meta Tags -->
<meta name="citation_title" content="<?php if(get_post_meta($post->ID, "vw_citation_title", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_title", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_1", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_1", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_2", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_2", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_3", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_3", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_4", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_4", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_5", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_5", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_6", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_6", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_7", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_7", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_8", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_8", true);?>">
<meta name="citation_author" content="<?php if(get_post_meta($post->ID, "vw_citation_author_9", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_author_9", true);?>">
<meta name="citation_publication_date" content="<?php if(get_post_meta($post->ID, "vw_citation_publication_date", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_publication_date", true);?>">
<meta name="citation_journal_title" content="<?php if(get_post_meta($post->ID, "vw_citation_journal_title", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_journal_title", true);?>">
<meta name="citation_volume" content="<?php if(get_post_meta($post->ID, "vw_citation_volume", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_volume", true);?>">
<meta name="citation_issue" content="<?php if(get_post_meta($post->ID, "vw_citation_issue", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_issue", true);?>">
<meta name="citation_firstpage" content="<?php if(get_post_meta($post->ID, "vw_citation_first_page", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_first_page", true);?>">
<meta name="citation_lastpage" content="<?php if(get_post_meta($post->ID, "vw_citation_last_page", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_last_page", true);?>">
<meta name="citation_pdf_url" content="<?php if(get_post_meta($post->ID, "vw_citation_pdf_url", true) !=\'\' ) echo get_post_meta($post->ID, "vw_citation_pdf_url", true);?>">