我想我会劫持画廊的短代码。
function my_gallery_shortcode($atts) {
global $post;
$str = gallery_shortcode($atts);
$project_title = get_post_meta($post->ID, "Project_Title", true);
$project_date = get_post_meta($post->ID, "Project_Date", true);
$project_location = get_post_meta($post->ID, "Project_Location", true);
$str .= \'<div class="project_details">\';
$str .= \'<div class="project_details_title">\'.$project_title.\'</div>\';
$str .= \'<div class="project_details_date">\'.$project_date.\'</div>\';
$str .= \'<div class="project_details_location">\'.$project_location.\'</div>\';
$str .= \'</div>\';
return $str;
}
add_shortcode(\'gallery\',\'my_gallery_shortcode\');
应该可以,但可以打印出来
div
不管是否设置了元值,所以我会写一些条件来保持整洁。
if (!empty($project_title)) {
, 等等--这样您只需打印您需要的内容。
您也可以注册add_shortcode(\'my_project_gallery\',\'my_gallery_shortcode\');
并且根本不接管默认的库。