• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
seegatesite header

Seegatesite.com

Seegatesite.com - Programming Tutorial , Sharing , How and Learn Together

  • TOOLS
    • Bootstrap Navbar Online Generator
    • Customize Sidebar Menu Bootstrap 3
    • Bootstrap Demo
  • ADVERTISE
  • CATEGORIES
    • Android
    • Blogging Tips
    • Database
    • CSS
    • Info Gadget
    • Javascript
    • Linux
    • PHP
    • Various
    • WordPress
  • Q&A
  • PHP
  • JAVASCRIPT
  • JQUERY
  • ANGULAR
  • WORDPRESS
  • SEO
  • REACT
🏠 » PHP » How To Create Custom Post Meta Boxes Wordpress Using Option-tree Framework

How To Create Custom Post Meta Boxes WordPress Using Option-tree Framework

By Sigit Prasetya Nugroho ∙ November 25, 2015 ∙ PHP, Wordpress ∙ Leave a Comment

Share : TwitterFacebookTelegramWhatsapp

Seegatesite.com – I will continue my article on how to use option-tree framework. This discussion is a continuation of my previous article about simple way create wordpress theme option using option tree framework. The use of meta boxes using the option tree framework will allow us to create custom fields in wordpress post’s page.

Meta boxes have a variety of uses, for example to improve SEO ONPAGE on your post page, we can create a meta boxes to include the meta description and meta keywords. If you sell products, you can create meta boxes to include price, product images, ratings and additional parameters.

Option tree framework is a powerful plugin which very helpful to wordpress theme’s developers. With a bit of coding we have offered variety of panels and meta boxes that responsive.

Table of Contents

  • 1 Here’s how to create a custom meta boxes using option-tree framework
    • 1.1 Thus article about how to create custom post meta boxes wordpress using option-tree framework, hope useful 🙂

Here’s how to create a custom meta boxes using option-tree framework

1. Surely you already have the option-tree framework plugin
2. Add the following script on the functions.php file in your theme

Related Articles :

  • Simple Way Create WordPress Theme Option Using Option Tree Framework

1
2
3
4
5
6
add_filter('ot_show_pages','__return_false');
add_filter('ot_show_new_layout','__return_false');
add_filter('ot_theme_mode','__return_true');
include_once('option-tree/ot-loader.php');
include_once('option-tree/meta-boxes.php');
include_once('option-tree/theme-options.php');

3. Create new php file as metaboxes.php and save on option-tree folder( your theme folder -> option-tree ) and copy this following code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php add_action( 'admin_init', 'custom_meta_boxes' ); function custom_meta_boxes() { $my_meta_box = array( 'id' => 'my_meta_box',
    'title'       => __( 'Example Meta Box', 'theme-text-domain' ),
    'desc'        => '',
    'pages'       => array( 'post' ),
    'context'     => 'normal',
    'priority'    => 'high',
    'fields'      => array(
      array(
        'label'       => __( 'Tab 1', 'theme-text-domain' ),
        'id'          => 'Tab_one_id',
        'type'        => 'tab'
      ),
      array(
        'label'       => __( 'Text', 'theme-text-domain' ),
        'id'          => 'text_box_meta',
        'type'        => 'text',
        'desc'        => __( 'This is a example of text field meta boxes.', 'theme-text-domain' )
      ),
      array(
        'label'       => __( 'Tab 2', 'theme-text-domain' ),
        'id'          => 'tab_two_id',
        'type'        => 'tab'
      ),
      array(
        'label'       => __( 'Textarea', 'theme-text-domain' ),
        'id'          => 'textarea_meta',
        'type'        => 'textarea',
        'desc'        => __( 'This is a example Textarea field.', 'theme-text-domain' )
      )
    )
  );
  if ( function_exists( 'ot_register_meta_box' ) )
    ot_register_meta_box( $my_meta_box );
 
}

Save, then go to your new post page ( Posts -> Add New ), You will see the results of the meta boxes that have been made like the following picture

How To Create Meta Boxes Option-Tree Framework

An outline, the code in the theme options and meta boxes are the same, the difference in meta boxes we don’t need to create a section to add a new tab.

The use of meta boxes on the theme’s building is using the following syntax

$demo_meta_box = get_post_meta( post_id_wordpress, meta_box_id, true );

or

$demo_meta_box = get_post_meta( $post->ID, 'demo_meta_box', true );

For detail tutorial, you can learn more from meta boxes demo example on (option-tree -> assets -> theme-mode)

Thus article about how to create custom post meta boxes wordpress using option-tree framework, hope useful 🙂

Another PHP Related Post :

  • Tutorial Create Simple POS Using ReactJS And Laravel Lumen Part 1
  • How To Replace String With Another String In PHP
  • Login Page – Tutorial CRUD Client and API Server Using JQuery And Lumen Part 2
  • Tutorial CRUD Client and API Server Using JQuery And Lumen Part 1
  • How To Solve Problems Illegal mix of collations (latin1_swedish_ci,IMPLICIT) In Laravel
  • How To Resolve No ‘Access-Control-Allow-Origin’ Header In Lumen

Avatar for Sigit Prasetya Nugroho

About Sigit Prasetya Nugroho

This site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Welcome to my Home,

Avatar for Sigit Prasetya NugrohoThis site is a personal Blog of Sigit Prasetya Nugroho, a Desktop developer and freelance web developer working in PHP, MySQL, WordPress.



Popular Articles

Checked checkbox AdminLTE Bootstrap in Jquery

November 4, 2014 By Sigit Prasetya Nugroho 7 Comments

Simple create date format validation with jqueryUI

December 21, 2014 By Sigit Prasetya Nugroho Leave a Comment

Create Simple Progress Bar for Fake Online Generator with Jquery

January 10, 2015 By Sigit Prasetya Nugroho Leave a Comment

22+ Coolest Free Jquery Plugin For Premium Theme

October 3, 2015 By Sigit Prasetya Nugroho Leave a Comment

Easy Build Your Anti Copy Paste Plugin

October 6, 2015 By Sigit Prasetya Nugroho Leave a Comment

Popular Tags

adminlte (15) adsense (13) adsense tips (4) affiliate amazon (13) amazon (12) Android (8) angular (16) angular 4 (12) angular 5 (4) asin grabber (3) Bootstrap (27) codeigniter (5) create wordpress theme (5) crud (8) css (6) free wordpress theme (7) google adsense (4) imacros (4) increase traffic (6) jquery (34) laravel (10) laravel 5 (5) learn android (5) lumen api (4) modal dialog (5) mysql (6) nodeJs (4) optimize seo (4) pdo (6) php (30) plugin (53) pos (8) Publisher Tips (5) react (6) Reactjs (9) SEO (37) theme (17) tutorial angular (5) tutorial angular 4 (6) tutorial javascript (10) tutorial javascript beginners (4) twitter (3) wordpress (18) wordpress plugin (13) XMLRPC (5)




  • About
  • Contact Us
  • Disclaimer
  • Privacy Policy
  • Terms and Conditions

©2022 Seegatesite.com