Why this didn’t work if i use get_the_ID(), but works if i pass the numeric id
Question
It is a custom meta box that handles pdf upload. I want to get the URL of the uploaded file. Inside admin, it works but on the homepage, it doesn’t work.
function moin_notifications_get() {
// Get the 'Profiles' post type
$args = array(
'post_type' => 'mmi-notification',
);
$loop = new WP_Query($args);
$file = get_post_meta(the_ID(), 'wp_custom_attachment', true);
echo '<ul class="moin-notifications">';
while($loop->have_posts()): $loop->the_post();
echo '<li class="moin-note-single"><a href="'. $file['url'] .'">'. get_the_title() . '</a></li>';
endwhile;
echo '</ul>';
wp_reset_query();
}
Following way it will work.
get_post_meta('6211', 'wp_custom_attachment', true);
Any idea, where I am doing the wrong thing. The problem is with the id.
Edit:
Earlier I used get_the_ID()
and that didn’t work.
0
4 months
0 Answers
16 views
0
Leave an answer
You must login or register to add a new answer .