Not sure if this is a WordPress issue, but I don’t think so.
I have a while
loop where I’m iterating over a user-created loop of content and trying to get a meta field, which has a numeric identifier which matches the current “key” (if you can call it that, since this is not an array at all, just a custom loop the user can create with some front-end parameters. $this_label_url
is requesting the faux “key” via the interpolation with $this_label_url = get_post_meta($post->ID, 'instructor_{$number}_label_url', true);
. Is variable interpolation not possible in this scenario?
<?php
$total_panels = get_post_meta( $post->ID, 'total_panels', true ); // set by the user with a custom meta value called "total_panels" (an integer)
$count = 1; // just a fake "key" for looping through my `while`
// create a faux "number" - simply takes $count and adds leading zero if not present
while ( $total_panels >= $count ) :
if ( $count >= 9 ) {
$number = '0' . $count;
} else {
$number = $count;
}
$this_label_url = get_post_meta($post->ID, 'instructor_{$number}_label_url', true); // returns as an empty string,
It is possible, but you need to use double quotes; single quotes aren’t parsed for interpolation.