WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top


Now i am using WordPress, here right now i have a problem How can i valid my text filed input only inter value. Here is my code

  <label for="<?php echo $this->get_field_id('num_post'); ?>">
    <?php _e( 'Number of posts to show:' ); ?>
    <input id="<?php echo $this->get_field_id( 'num_post' ); ?>" name="<?php echo $this->get_field_name( 'num_post' ); ?>" type="text" value="<?php echo   $instance['num_post']; ?>" size="3" />
share|improve this question
<?php print (int) $instance['num_post']; ?>

or possibly:

<?php print absint( $instance['num_post'] ); ?>

Use the second one to avoid negative values.

share|improve this answer
thanks, its really works – Webd106 Jun 23 '11 at 2:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.