When i try to get post ID it returns the ID of the cloud template not the ID of the actual single post.
the cloud template ID is:215 the single post ID is:1911 the following code will only output 215
`
function metavalue() {
global $post;
$meta = get_post_meta($post->ID, 'product_url', true);
return $meta
}
add_shortcode('url_short', 'metavalue');
get_the_ID(); the_id(); $post->ID; will also output 215. i need a way to get the actual single post ID so i can get the custom field value from ‘product_url’.
-
This topic was modified 7 years by
vexicon.
Hello,
Is there an answer to this question ? I’m working on a template but Cloud Template overrides the_ID() value of the “real” post displayed đ
Thanks for you answer but after thousands of lines read, I believe I found an even better way !
global $tdb_state_single;
$post_id = $tdb_state_single->get_wp_query()->post->ID;
I had to go with vexicon solution, though I think this is messy with all the extra calls and look forward to finding a better solution. I think part of the issue is where I am altering the plugins code it runs multiple times and the last Get-ID is always a template, so grabbing URL > ID seems to be the only solution so far.