• Stuart Blackett

    (@stuartkoodoocreativecouk)


    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 of 32, rather than 0?

    That amount will change dependant on what the user inputs into the WYSIWYG editor.

Viewing 1 replies (of 1 total)
  • try:

    <input type="text" name="counter-value" value="<?php the_content(); ?>" />

    or in case that ‘the_content()’ outputs other html tgs as well,
    try and use echo $loop->post_content;

    example:

    <input type="text" name="counter-value" value="<?php echo $loop->post_content; ?>" />

    how does the output look like, if you view the source code of your site in the browser?

Viewing 1 replies (of 1 total)
  • The topic ‘Reading post content into a hidden field..?’ is closed to new replies.