所以基本上我正在尝试编辑一个名为 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);