douzuita7325 2019-08-02 20:34
浏览 44

自定义下载小部件:使下载监视器与高级自定义字段一起使用

I cannot find an appropriate plugin for this, but I want to have a related downloads list on various sidebars that are specifically related to the current page/post. Suppose an article has a presentation & questionnaire for downloads. I want them to appear in my sidebar on that page. I'm currently using Advanced Custom Fields (ACF) and Downloads-Monitor (DLM).

I want this to be something that the user either tags the appropriate post from the download manager, or tags the appropriate download link from the post. Perhaps there's an existing plugin that I'm unaware of?

I added a document to the DLM and tried adding a custom field called "related_download" with a value of the slug for the page I'm testing (i.e. events). I attempted to call the new field and see if it matches what the current page's slug is. If it does, run the proceeding code for the list.

<div class="widget widget_related_docs">
  <h4>Related Downloads</h4>
  <div class="side-content">
    <ul>
      <?php echo do_shortcode('[downloads category=related-download order=ASC template="my-template"]'); ?>
    </ul>
  </div>
</div>

<?php
/**
 * Detailed download output
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
} // Exit if accessed directly

if ( $dlm_download->get_field('related_download') ) :
  global $post; // get the post meta and search for slug
  $post_slug = $post->post_name;

  if ( $dlm_download->the_field('related_download') = $post_slug ) :

?>

<li>
  <a href="<?php $dlm_download->the_download_link();?>" target="_blank"><?php $dlm_download->the_title();?></a>
</li>

<?php 

  endif;
endif;

?>

Unfortunately, the page doesn't finish loading due to some error. I've been away from WordPress development for a while, so I'm hoping that this is something easy.

Any help is appreciated. Thanks!

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100