The Rundown:
我正在使用a Wordpress Plugin来管理我的可下载内容,而我正试图弄清楚如何在前端显示“上传日期”。我添加了我认为可以完成工作的代码,但什么都没发生。
我找到了3个我认为应该关注的领域。
PHP:
function handle_sdm_download_via_direct_post() {
if (isset($_REQUEST['smd_process_download']) && $_REQUEST['smd_process_download'] == '1') {
global $wpdb;
$download_id = strip_tags($_REQUEST['download_id']);
$download_title = get_the_title($download_id);
$download_date = get_the_date($format, $post_id);
$download_link = get_post_meta($download_id, 'sdm_upload', true);
我添加了$download_date = get_the_date($format, $post_id);
// Create array of variables to pass to js
$final_array[] = array('id' => $post->ID, 'permalink' => get_permalink($post->ID), 'title' => $post->post_title, 'date' => $post->post_date);
我添加了, 'date' => $post->post_date)
JS:
// Populate each matched post title and permalink
$this.children('.sdm_placeholder').append('<a href="'+value['permalink']+'"><span class="sdm_post_title" style="cursor:pointer;">'+value['title']+'</span></a><span class="sdm_post_date">'+value['date']+'</span>');
我添加了<span class="sdm_post_date">'+value['date']+'</span>
部分,但我不确定这是否正确,我不确定我是否在PHP中正确定义:/
必要时链接到文件:
PHP: https://drive.google.com/file/d/0B6C2-SqaSCluYXZlcmUtNFF0NzA/view?usp=sharing
JS: https://drive.google.com/file/d/0B6C2-SqaSCluenVSRFpzV3V3Z0E/view?usp=sharing