-
Notifications
You must be signed in to change notification settings - Fork 422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding custom class to fields? #141
Comments
You can use
|
I'm sorry to say, but I am stuck: Here is the snippet from what you are suggesting: add_filter( 'rwmb_begin_html', 'add_my_class' ); function add_my_class( $begin, $field, $meta ) { $class = 'rwmb-label'; if ( ! empty( $field['class'] ) ) $class = self::add_cssclass( $field['class'], $class ); if ( empty( $field['name'] ) ) return ' When I do that I get this error: I am simply trying to change 'div class="rwmb-field"' to div class="rwmb-field-id" (id is the id of the field being shown) Sorry for the newb question, but I spent the entire evening,morning trying every combination that I could think of, and nothing is working. Can you show me where I am going wrong? |
sorry about the formatting above, can't figure out why git is not closing off my code snippet the right way..... |
Please try: |
Btw, it needs to be 10, 3 not 10,2... Here's what I ended up with. It doesn't do what I want "remove the rwmb-field" and replace it with "rwmb-field field-id", as I can't seem to figure out how to modify that wrapper div. However it does work for me to get by for now.
Probably a lousy way of doing it, but I'm still learning. Thnx for the pointer |
Damn it's hard to get github to take my code without screwing it up... arghh. I am wrapping my code with (pre)(code) and ending it with (/code)(/pre) obviously changing ( for a < https://gist.github.com/3140691 works better |
Hi, github uses Markdown syntax to parse comments, you can click the link to see the details. Looks like your code is good, so I'll close this ticket. |
I needed to have field specific classes in order to target them via jQuery. Now I know I can add a class manually during creation of the field but I'm lazy.
One idea was to simply add this line to the meta-box.php class line 259
$class = $this->add_cssclass( $field[ 'id' ], $class );
Obviously I don't want to hack the core file, and I did see a filter hook in there, but I just could not figure out how to write a filter to add the field id as a class to all the fields.
If the filter can be used for this, can someone copy a working snippet in here for me to use?
*I'm not even sure if the filter I was trying would work, hence the question.
The text was updated successfully, but these errors were encountered: