I have a Custom Post Type called Form
and I am attaching only a PDF file in the post using the post editor like this
I have loop like
<?php
$args = array(
'post_type' => 'form',
'post_status' => 'publish',
'posts_per_page' => 200,
'orderby' => 'publish-date',
'order' => 'ASC',
'tax_query' => array(
array(
'taxonomy' => 'forms',
'field' => 'slug',
'terms' => 'personal-services',
),
),
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query ->the_post();
?>
<div class="card mb-3 news-card">
<div class="row g-0">
<div class="col-md-12">
<div class="card-body pb-0 pt-3">
<h5 class="card-title"><?php echo get_the_title(); ?></h5>
<p class="card-text"><?php echo get_the_excerpt(); ?></p>
<p class="card-text"><?php echo get_the_content(); ?></p>
<div class="row">
<div class="col-12 col-md-6 col-lg-6 mb-2 pt-3">
<span class="card-text"><small class="text-muted">Published at: <?php echo get_the_date('l F j, Y' ); ?></small></span>
</div>
<div class="col-12 col-md-6 col-lg-12 mb-2">
<span role="button" class="card-text new-btn d-block rounded">Download - <?php echo pdf_attachment_file("1",""); ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
endwhile;
wp_reset_postdata();
?>
the <?php echo get_the_content(); ?>
is exporting the PDF file on the page but I need to get the URL of the attachment. Can you please let me know how to do this?