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 8858565
In Process

The Archive Base Latest Questions

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

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

  • 0

I have an options panel in my WordPress theme with several text fields. For example: Project title, Project description, Twitter username, 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?

The input IDs for the text fields are mytheme_projectitle1, mytheme_projectitle2, mytheme_projectitle3, mytheme_twitterusername etc. I don’t have an input class for any of them, just the ID.

  • 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:51:32+00:00Added an answer on June 14, 2026 at 2:51 pm

    You can access the id for each element with $value['id'] as is apparent from the code. Use that to derive a maximum length, for example this way:

    case 'text':
        // Overrides for the default value of maxlength
        $maxlengths = array(
            'mytheme_projecttitle1' => 10,
            'mytheme_projecttitle2' => 20,
        );
    
        // If there is an override value use it; otherwise use the default of 12
        $maxlen = isset($maxlengths[$value['id']]) ? $maxlengths[$value['id']] : 12;
    
        $val = $value['std'];
        $std = get_option($value['id']);
        if ( $std != "") { $val = $std; }
    
        $output .= '<input class="" maxlength="'.$maxlength.'"..."; // the rest as before
    
    • 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 e.g.
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'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
I am new to magento. I have added two text fileds(custom options) for products

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.