<?php

/*
*
* Attachments display
*
*/
?>

<?php 
$attachments = hkb_get_attachments();
?>

<?php 
if (!empty($attachments)) {
    ?>

    <!-- .hkb-article-attachments -->
    <section class="hkb-article-attachments">
        <h3 class="hkb-article-attachments__title"><?php 
    _e('Article Attachments', 'ht-knowledge-base');
    ?>
</h3>
        <ul class="hkb-article-attachments__list">
            <?php 
    foreach ($attachments as $id => $attachment) {
        ?>
                <?php 
        $attachment_post = get_post($id);
        $default_attachment_name = __('Attachment', 'ht-knowledge-base');
        $attachment_name = !empty($attachment_post) ? $attachment_post->post_name : $default_attachment_name;
示例#2
0
 /**
  * Has attachments
  * @return (Int) Count attachments
  */
 function hkb_count_attachments($post_id = null)
 {
     global $post;
     $post_id = empty($post_id) ? $post->ID : $post_id;
     $attachments = hkb_get_attachments($post_id);
     $has_attachments = empty($attachments) ? 0 : count($attachments);
     return $has_attachments;
 }