I am messing around with Wordpress and WP_Query and I am wondering how I may be able to get the URL for the file that ends up being linked when I use $post->post_content or $this_post['post_content'];
In my post I just set up there to be a file upload of a PDF with a title. No preview, no download link.
At this point I am just given a link that is similar to the PDF file name. I know I can probably just extract the link using some other function but I figured there must be some way to get to the array of the content and then just extract the entire file path, including the wp_uploads/month/day/x.pdf URL.
$press_pdfs = new WP_Query(
array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 4,
'category_name' => 'press-files'
)
);
<?php if ( $press_pdfs->have_posts() ) : ?>
<div class="blog-posts">
<h3 class="news__heading">PRESS RELEASES</h3>
<?php while ( $press_pdfs->have_posts() ) : $press_pdfs->the_post();
$postID = get_the_id(); ?>
<div>
<hr>
<?php
$this_post = get_post($postID, ARRAY_A);
echo '<pre>';
print_r($this_post);
echo('hi');
echo '</pre>';
echo($this_post['post_content'];
echo apply_filters('the_content', $post->post_content);
?>
<hr>
</div>
<a href="<?php echo $url; ?>" class="" target="_blank">
<h4 class="post-title"><?php the_title(); ?></h4>
</a>
<?php endwhile; ?>
</div>
<?php endif;
wp_reset_postdata(); ?>
In this example this_post['post_content'] and post->post_content give me the same result, which is the link. I want to get the full URL from that link.