Hide the whole metabox cmb2 - php

i'm using the famous CMB2 to create custom metaboxes, i want to have one hidden field with default value which i will set myself. i used this hidden field type and its working fine , the thing is the metabox will have this field only, so i ended up with what looks like an empty metabox which may confuse the user. i have read dispaly options but this controls where should the metabox appear, i have it exactly where i want on my posts but i want to set it's visability to be hidden so i do not confuse the user , i thought about using css on this but i want to check if there is a way to achieve this using CMB API

i'm adding the css way answer because it works and achieves the requirement , but i would still like to know if there is another php way for educational purpose.
function admin_style() {
wp_enqueue_style('admin-styles', get_template_directory_uri().'/css/admin-css.css');
}
add_action('admin_enqueue_scripts', 'admin_style');

Related

Display custom field tabs in front end article edit page in Joomla 3.x

I have been looking for a solution to display custom field tabs in the Joomla
front article edit page.
http://www.aixeena.org/extensions/aixeena-easy-cck
Aixeena Easy CCK
I installed the plugin of aixeena, two custom field tabs: the Extra content and Extra content 2 are displayed in the backend admin article edit page, which is great. But we also need to let regular edit their article and enter values in custom fields under those two tabs. Any idea how to achieve this?
I tried a couple of other sites posting the solution of adding custom fields in article, such as Rating region described in the site:
https://docs.joomla.org/Adding_custom_fields_to_the_article_component
I was not able to make the Rating tab displayed in the front end article edit page neither.
I tried the fieldattach, it does supports custom field tab ( which is the group name of custom field), the list field type only contains static values, we have to define fieldset and field type through xml file.
Any help is greatly appreciated.
I just finished writing a couple pluginsto do this similar thing. I wrote my own plugin to add the extra fields - but it looks like the one you've already used is very similar.
I had a really hard time figuring out how to add the fields for frontend editing as well. But I finally figured it out.
First, you're going to need to copy the com_content form edit.php into a template override (/templates/your_template_name/html/com_content/form/edit.php).
In that file, add the extra fields you have. You'll need the name of the field that you put in the xml file for your plugin you already have. Add them right before/after the fields that are already in the file, that you want your fields to appear before/after. Example:
<!-- CUSTOM begin custom fields -->
<?php echo $this->form->renderField('video_url', 'attribs'); ?>
add all your fields in there - replacing 'video_url' with your own field name. The plugin you already have already saved these fields to the 'attribs' part of the article, so you can leave that there.
The plugin that I used to create the fields for the backend is a really simple one based off of this tutorial https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla
What I'd suggest is to go ahead and create that plugin too. Except in the zfields.php file, change "$app->isAdmin()" to "$app->isSite()" - make sure the xml files have the same names as your other plugin xml files, so they save to the same place, and you're done. The fields will show up on the frontend edit form now.
What I'd really recommend is to get rid of the Aixeena plugin, and just make that easy plugin using the tutorial above - it's super easy. When you make it, duplicate the "if ($app->isAdmin())" section, copy it right below it, and change "isAdmin" to "isSite" - and now you've got the entire thing, all your custom fields, both frontend and backend, all in one place. Now just do the edit.php template override, and you'll have them displayed in both the front and backend. I hope that helps - if you need I can upload more example code.

How to display html content in Wordpress Custom Field?

Introduction:
I'm using wordpress theme called ClassiPress I'm very familiar with custom fields and how to use and display them.
In that theme you have ability to create custom fields and than display them for normal users when they are publishing an advertisement (it's cassified ads theme).
Problem:
I want to display custom field in which would be displayed html content in this case table which people would fill up with information and later i would display that table in their post .
( sentence in bold text means that i know how to do that part.)
Note: I know that by doing this i even risk to get xss holes.
Question:
Is it possible to display custom field with html content in it? Int his case it would be simple html table.
What i have tried:
Well since I'm not sure even hfrom what to start i have tried really cheezy and maybe even funny method i have created custom field as text area and went to mysql found that custom field and tried put content in that field in this case just simple <b>It Works</b> code to see if that would display bolded text in that text area. But it didn't work maybe becausein database there wasnt right tab;le for it or i did something wrong.
Additional Information:
Please also note that in that theme which has custom fields they are limited that means i can't create things that allowed in other custom fields plugins. Pleas etake a look at picture bellow which custom fields tylpes it supports:
Please click here in order to see image
I would be very thankfull to person which would provide me any solution it could be alternative way but overal would do the idea that i want which i hope i have explained well.
None of those form elements allow raw HTML. If you are going to put HTML in an input field or textarea, it will need to be HTML-encoded. For example:
<b>It Works</b>
would need to be:
<b>It Works</b>
There are various ways to do that, but it might be hard to make it user-friendly.

Modify how Drupal builds fields on a per form basis

I want to change the way Drupal builds specific fields on a specific node edit/add form on my site. For example, when I use print drupal_render($form['textarea']); in my node--CONTENTTYPE--form.tpl.php file, I get the default Drupal render of the field widget. I want to modify the HTML markup of the field widget.
There are three ways I can think of that might solve this problem:
Using a forms equivalent of the theme_field() hook. This seems ideal, but after searching for the last few hours, I haven't found anything on this.
Building custom field widgets for every field type I'm using on that node. This is definitely not ideal and I have to believe there's an easy way to do this in Drupal from a theme point of view.
Manually build the HTML markup for the form and field in node--CONTENTTYPE--form.tpl.php with print $form['textarea']['und'][0]['title']; and the like.
Is there a hook in Drupal to do this, or must the code for every field I want to modify be manually generated?
I think the hooks you are looking for are hook_form_alter and hook_form_BASE_FORM_ID_alter. Refer to the Form API to know what you can set on the render array.

Wordpress - Don't show Advanced custom field meta in default Custom Fields dropdown

I'm using the plugin ACF which uses the wordpress meta data Or something similar to save the field name/content.
The problem I have is, I use the default wordpress Custom Fields for a few things, but once you've added a few fields through ACF it fills the list with generated content.
Which makes it hard for the client to find the fields that are used e.g tagline.
Is there anyway to filter what is output here?
Try using an underscore as a first character of your custom field name for ACF. Like _performances or _mycustomfield This would make the custom field hidden into the native custom field form in each post. For reference read it here.

wordpress my own custom field

I want to make custom fields in WordPress post.
I am a developer and want to create my own custom field. I don't want to use the default custom fields that are available when we install WordPress. In fact, I want to add radio
buttons and a check box from where I could select them as you can see in the image I attached.
How do I go about this?
Everything will be done in functions.php.
You have to declare your extra fields (meta boxes). This article will give you all the explanations : http://www.farinspace.com/how-to-create-custom-wordpress-meta-box/
It should give you all the info you need to add meta boxes (see also : http://codex.wordpress.org/Function_Reference/add_meta_box)

Categories