I have this php code:
<?php if ( $hide_all_info == 0 ) { ?>
<span class="film_meta_wrap">
<div class="film_meta_title"><?php echo the_title(); ?></div>
<div class="film_meta_text"><?php echo $film_meta_info; ?></div>
</span>
<?php } elseif ( $hide_all_info == 1 ) { ?>
<span class="film_meta_wrap"></span>
<?php } ?>
I need to move/append the result of that if statement into an existing div within the current loop item like so:
jQuery( ".film_meta_wrap" ).appendTo( ".arve-embed-container" );
My current result is as expected, but not what I need to do: all of the code is appended regardless of said if statement, and it also places the same spans in every loop item (ie. doesn't honor the loop it resides within for individual posts). Does that make sense? How would I get the jQuery to append the one span after the php variables and conditionals are parsed and populated. And for each loop item. Is it even possible? Ajax would be an acceptable solution, just don't know how that would work.
EDIT** I modified the suggested code to also append the elseif result:
<?php if ( $hide_all_info == 0 ) { ?>
<script>
var _html = '<span class="film_meta_wrap">'
+'<div class="film_meta_title"><?php echo the_title(); ?></div>'
+'<div class="film_meta_text"><?php echo $film_meta_info; ?></div>'
+'</span>';
jQuery('.arve-embed-container').append(_html);
</script>
<?php } elseif ( $hide_all_info == 1 ) { ?>
<script>
var _html = '<span class="film_meta_wrap"></span>';
jQuery('.arve-embed-container').append(_html);
</script>
<?php } ?>
You can do:
Finally made it work
Do: