Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8856927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:28:09+00:00 2026-06-14T14:28:09+00:00

I have an options panel in my WordPress theme with several text fields e.g.

  • 0

I have an options panel in my WordPress theme with several text fields e.g. project title, project description, etc.

case 'text':
        $val = $value['std'];
        $std = get_option($value['id']);
        if ( $std != "") { $val = $std; }
        $output .= '<input class="" maxlength="12" name=""'. $value['id'] .'" id="'. $value['id'] .'" type="'. $value['type'] .'" value="'. $val .'" />';
    break;

As the above code shows… I currently have my max length for the text fields as 12, but I would like to have a max length to be different for each of the text fields. How can I do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:28:10+00:00Added an answer on June 14, 2026 at 2:28 pm

    Define an array containing the fields and their corresponding maxlength values.
    (I’ve used field names, but you could also use an Id number)

    E.g: field_name => max_length_for_that_field

    $maxFieldLengths = array(
        'project_title' => 12,   //project title has 12 max length
        'project_description' => 100   //project description has 100 max length
    );
    

    Identify which text field (input) you are currently building and use that identifier to reference your maxFieldLengths array.

    case 'text':
        ...
        $field_name = // Identify the current field here;
        $output .= '<input class="" maxlength="'. $maxFieldLengths[$field_name] .'" etc .....' />
    break;  
    

    Note: From your code sample it’s not 100% clear how you identify the field you are currently building. You could, for example, use something like:

    ...
    $field_name = getFieldFromId($value['id']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an options panel in my WordPress theme with several text fields. For
I have a option in my Wordpress theme options panel that I made to
I have built a WP theme with an options panel, and I have a
I have created a theme options panel for a client however they would like
i've been working on a theme options panel for wordpress. but i've run into
This is a PHP problem in WordPress while using a custom theme options panel.
I have writen options to a <select> using something like Id.innerHTML = <option value='foo'>Foo</option>;
I'm building a custom WordPress theme and have a quick question regarding WordPress and
In my options panel I have a section where the user can enter their
I have a firefox extension Options pref panel, where I should dynamically create menu

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.