admin管理员组文章数量:1122846
I'm working on a function for bibliographic citations with get_post_meta.
A bibliographic citation contains several elements, (author, date, title, etc.), each of these elements is a get_post_meta value. The bibliographic citation function orders these elements according to bibliographic standards (e.g. APA).
Example
Function for elements the citation
function editorial() {
global $wp_query;
$post = $wp_query->post;
$editorial = get_post_meta($post->ID, 'acervo_editorial', true);
if (!empty($editorial)) {
echo $editorial.', ';
}
}
function pubdate() {
global $wp_query;
$post = $wp_query->post;
$pubdate = get_post_meta($post->ID, 'acervo_pubdate', true);
if (!empty($pubdate )) {
echo $pubdate.', ';
}
}
function for citation
function article_citation() {
global $wpdb;
global $wp_query;
echo '<p>';
editorial();
pubdate();
echo '</p>';
}
If I put the echo get_post_meta directly in the template it works
$pubdate = get_post_meta($post->ID, 'acervo_pubdate', true);
if (!empty($pubdate )) {
echo $pubdate.', ';
}
but if I put the citation function some elements work and others don't. Something is wrong but I don't know what it is.
article_citation();
本文标签: wp queryfunctions with getpostmeta
版权声明:本文标题:wp query - functions with get_post_meta 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309347a1933986.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论