Add Custom Field Key in functions.php - php

Is there any way to add custom field keys to the dropdown of the custom fields on the "add new post" page without adding the fields?

Check add_meta_box (It allows plugin developers to add sections to the Write Post, Write Page, and Write Link editing pages. ):
http://codex.wordpress.org/Function_Reference/add_meta_box
Or these plugins:
Custom Field Template: http://wordpress.org/extend/plugins/custom-field-template/
Flutter: http://flutter.freshout.us/ (this one may be what you are looking for)
Magic Fields: http://wordpress.org/extend/plugins/magic-fields/
Source: http://sltaylor.co.uk/blog/control-your-own-wordpress-custom-fields/

Adding Meta Boxes is definitely the way to go. The following should help you:
http://farinspace.com/wordpress-meta-box-next-level/
http://farinspace.com/custom-fields-area-uncluttered/

Related

Hide the whole metabox cmb2

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');

Custom input fields Wordpress back-end

I am working on a food-blog theme for Wordpress and I want the admin user to be able to add recipies in the back-end.
I'm thinking of a custom post format section similar to the regular post section where the user can add a title, the post itself, an excerpt etc.
I know how I can make such a section, but I want a custom field/row where the user adds an ingredient such as "water" and can add an amount and adds "grams"/"kilograms" etc. And do this for every ingredient.
I hope someone can help me with this, thanks!
Using Advanced custom fields
Documentation below
http://www.advancedcustomfields.com/resources/creating-a-field-group/
You can create fields that a user can insert data into and then you just parse that data into the the single page.
It is all documented nicely on the link above.

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.

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)

Filtering custom fields on wordpress admin page

I'm currently working on a wordpress 2.9.2 plugin (my first) that creates additional custom fields that will later be read from the template. The plugin adds an additional meta box to the "Edit Post" screen which is responsible for manipulating these values.
My problem is that the custom fields generated by the plugin also show up in the "Custom Fields" box. Ideally I would like for the custom fields generated by the plugin to be managed separately from any other custom fields for that same post/page.
Is there a way that I can filter fields specific to my plugin to prevent them from being displayed in the "Custom Fields" box? I have yet to locate any action or filter that will let me capture and manipulate those values before they are rendered on "Edit Post".
Additionally, if you prefix your custom fields with and underscore "_" it will be hidden from the custom fields section.
Also, check out my WPalchemy Meta Box PHP Class which will help you create meta boxes with ease.
If you take a look inside the function _list_meta_row() (around line 2500 in wp-admin/includes/template.php), you'll see it skips post meta that is a serialized array or object.
So, if you can see fit to store your plugin post meta as an array or object, it shouldn't show in the Custom Fields box.

Categories