Custom post type
Set customfield.
Custom field can be setted by plugin. But it is not flexible to get the values and use them.
WPAlchemy gives flexibility to customfield.
How to use WPAlchemy?
- Download WPAlchemy.
- Open zip file and check contents.
- wpalchemy-master/wp-content
- wpalchemy
- MediaAccess.php
- MetaBox.php
- themes
- mytheme
- metaboxes
- checkbox-meta.php
- checkbox-spec.php
- full-meta.php
- full-spec.php
- meta.css
- radio-meta.php
- radio-spec.php
- select-meta.php
- select-spec.php
- setup.php
- simple-meta.php
- simple-spec.php
- functions.php
- metaboxes
- mytheme
- Put metaboxes in using theme folder.
- Put wpalchemy in wp-content folder.
- The contents in functions.php of WPAlchemy transfer to functions.php in your theme.
- Create template_metabox.php in metaboxes folder. Refer other php files as full-meta.php. This is frame of customfield.
↓example.↓
12345678910111213141516<div class="my_meta_control"><h4>Related articles</h4><a style="float:right; margin:0 10px;" href="#" class="dodelete-docs button">Remove All</a><?php while($mb->have_fields_and_multi('docs',array('length' => 1, 'limit' => 3))): ?><?php $mb->the_group_open(); ?><?php $mb->the_field('rURL'); ?><p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>"/></p><?php $mb->the_group_close(); ?><?php endwhile; ?><p style="margin-bottom:15px; padding-top:5px;"><a href="#" class="docopy-docs button">Add Document</a></p></div> - Add script setup.php and set customfield.
1234567$custom_checkbox_mb = new WPAlchemy_MetaBox(array('id' => '_images_meta',//rename _**_meta'title' => 'Images custom fields','template' => get_stylesheet_directory() . '/metaboxes/images_meta.php',//set appropriate file.'types' => array('images')// post type)); - Go to dashboard and input data.
- Get customfield value.
There are 2 ways of getting a value.
123$post->customfield key;get_meta_post($post->ID,'customfield key',true or false);
※OPTION: If you use media upload function, set it.
Reference
WordPressでカスタムフィールドを使うならWPAlchemyがおすすめ
WPAlchemy MetaBox PHP Class
How To Integrate the WordPress Media Upload Box Into Your Meta Boxes
comment
go to related tags archive?
SEARCH ARTICLES
in this site
TAG CLUSTER
LATEST COMMENT
in this site
No comment yet.