Posts

Showing posts from March, 2018

How to Create CPT in WordPress ?

Register Custom Post In WordPress <?php     /**      * Registers the "testimonial" post type.      */     add_action ( 'init' , 'ch_testimonials_post_type_register' );     function ch_testimonials_post_type_register () {         $labels = array (             'name'               => __ ( 'Testimonials' ,                     'ch-cpt' ),             'singular_name'      => __ ( 'Testimonial' ,                     'ch-cpt' ),             'all_items'          => __ ( 'All Testimonials' ,                 'ch-cpt' ),             'add_new'            => _x ( 'Add New' , 'testimonial' ,           'ch-cpt' ),             'add_new_item'       => __ ( 'Add New Testimonial' ,             'ch-cpt' ),             'edit_item'          => __ ( 'Edit Testimonial' ,                 'ch-cpt' ),

Wordpress Plugin Standards:

Header Requirements /** * Plugin Name: Example Plugin * Plugin URI: https://example.com/plugins/the-basics/ * Description: Basic WordPress Plugin Header Comment * Version: 1.0.0 * Author: Chirag Prajapati * Author URI: https://chrgprajapati.blogspot.com * License: GPL2 * License URI: https://www.gnu.org/licenses/gpl-2.0.html * Text Domain: example * Domain Path: /languages */ Define Basic Constant value define( 'EX_VERSION', '1.0' ); define( 'EX_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'EX_PLUGIN_DIR', untrailingslashit( dirname( __FILE__ ) ) ); define( 'EX_PLUGIN_URL', untrailingslashit( plugins_url( '', __FILE__ ) ) ); define( 'EX_CONTENT_URL', content_url( )); Above five is basic but you can define the extra variable as you want. like, define( 'EX_LOG_DIR', WP_CONTENT_DIR.'/uploads/ex_logs/'); define( 'EX_LOG_file', EX_LOG_DIR.'/ex_log.txt'