在wordpress中调用元数据


Calling meta data in wordpress

所以基本上我正在尝试编辑一个名为Showbiz的插件。他们将标题、作者、日期等帖子中的标准元数据称为:

$title = $this->getValue("title");
$alias = $this->getValue("alias");
$urlImage = $this->imageUrl;
$text = $this->getValue("slide_text");
$link = $this->getValue("link");
if(empty($link))
    $link = "#";
$date = $this->getValue("date");
$dateModified = $this->getValue("date_modified");
$excerpt = $this->getValue("excerpt");
$youtubeID = $this->getValue("youtube_id");
$vimeoID = $this->getValue("vimeo_id");
$authorName = $this->getValue("author_name");
$numComments = $this->getValue("num_comments");
$catList = $this->getValue("catlist");
$tagList = $this->getValue("taglist");
$postID = $this->id;
//replace the items in the html
$html = $this->replacePlaceholder("title", $title, $html);
$html = $this->replacePlaceholder("id", $postID, $html);
$html = $this->replacePlaceholder("alias", $alias, $html);
$html = $this->replacePlaceholder("name", $alias, $html);
$html = $this->replacePlaceholder("image", $urlImage, $html);
$html = $this->replacePlaceholder("content", $text, $html);
$html = $this->replacePlaceholder("link", $link, $html);
$html = $this->replacePlaceholder("date", $date, $html);
$html = $this->replacePlaceholder("modified_date", $dateModified, $html);
$html = $this->replacePlaceholder("excerpt", $excerpt, $html);
$html = $this->replacePlaceholder("youtube_id", $youtubeID, $html);
$html = $this->replacePlaceholder("vimeo_id", $vimeoID, $html);
$html = $this->replacePlaceholder("author", $authorName, $html);
$html = $this->replacePlaceholder("numcomments", $numComments, $html);
$html = $this->replacePlaceholder("catlist", $catList, $html);
$html = $this->replacePlaceholder("taglist", $tagList, $html);

我想做的是调用我的自定义帖子类型数据。要在一个普通的模板文件中做到这一点,我可以添加:

get_post_meta( get_the_ID(), 'META_DATA_NAME', true );

我不知道如何将其添加到模板中。我尝试添加下面的代码,但没有得到任何值。有人有什么想法吗?谢谢

$charity = $this->get_post_meta( get_the_ID(), 'META_DATA_NAME', true );
//replace the items in the html
$html = $this->replacePlaceholder("charity", $charity, $html);

getValue函数适用于任何post-meta还是仅适用于Showbiz已知的那些?你试过。。。

$charity = $this->getValue('META_DATA_NAME');
$html = $this->replacePlaceholder("charity", $charity, $html);