I have created a custom post type titled “Tea” it is the default post layout. The value of “32” is entered into the WYSIWYG editor.
I am looking through the data and I’d like to echo the_content(); into an hidden field. Which then creates a number counter based on the value of that field.
At the moment I am just getting the value of “0”
My code for it is as follows :
<div class="tea-count">
<?php
$args = array( 'post_type' => 'tea');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '
<div id="counter">
<input type="text" name="counter-value" value="the_content();" />
</div>';
?>
<?php endwhile; ?>
</div>
How do I get the value out to read 32, rather than 0?
That amount will change depending on what is entered by the user.
Thanks
You might need to use get_the_content(), because the_content() has built-in functions to print to the screen, and you’re already inside an
echo
.Also, you might need to change your single quotes to doubles and vice versa, or concatenate your string better.
This might work: