PHP Developer

Thursday, 9 April 2015

Create Custom Post with all options like Category, Featured image, Excerpt etc. in wordpress

Create Custom Post with all options like Category, Featured image, Excerpt etc. in WordPress


Copy and Paste this code in function.php file. This function create a post of type "servicerequest".

<?php
/*------------------------ Create Custom Post servicerequest START -------------------------------*/

function service_request() {
    $labels = array(
    'name' => 'Services',
    'singular_name' => 'Services',
    'add_new' => 'Add New Services',
    'add_new_item' => 'Add New Services',
    'edit_item' => 'Edit Services',
    'new_item' => 'New Services',
    'all_items' => 'All Services',
    'view_item' => 'View Services',
    'search_items' => 'Search Services',
    'not_found' => 'No Services Found',
    'not_found_in_trash' => 'No Services found in Trash',
    'parent_item_colon' => '',
    'menu_name' => 'Request Services',
    );
    //register_post_type is use to create new post type.
    //"servicerequest" is a post type

    register_post_type( 'servicerequest', array(
        'labels' => $labels,
        'has_archive' => true,
        'public' => true,
        'supports' => array( 'title', 'editor', 'excerpt', 'custom-fields', 'thumbnail', 'author', 'revisions', 'post-formats' ),
        'exclude_from_search' => false,
        'capability_type' => 'post',
    )
    );  
}
add_action( 'init', 'service_request' );

Wednesday, 8 April 2015

Send Email to multiple users when custom post or post is publish by admin

Send Email to multiple users when custom post or post is publish by admin

Step 1 .  Download PHPMailer from Download and save extract file on path "/wp-content/themes/funding_press" with directory name "PHPMailer".


Step 2 .  Paste this code in function.php file.

Add Meta Box Wordpress Editor for Post or Custom Post in Wordpress

Add Meta Box Wordpress Editor for Post or Custom Post in Wordpress

<?php
/*-------- Add Meta Box Wordpress Editor for Post Code START ----------*/

function myplugin_add_custom_box() {
    $screens = array( 'post' );  // Post Type
    foreach ( $screens as $screen ) {
        add_meta_box(
            'myplugin_sectionid',
            __( 'Product Detail', 'myplugin_textdomain' ),
            'myplugin_inner_custom_box',
            $screen
        );
    }
}

Saturday, 4 April 2015

Create a plugin in wordpress to add Multiple Number of posts, Meta Box And Featured Image from CSV

Create a plugin in wordpress to add Multiple Number of posts, Meta Box And Featured Image from CSV

1.  Create a directory with name “csv-upload”.
2.  Create files in directory  “csv-upload”
          a. csv-upload -> csv-upload.php
          b. csv-upload -> csv_queryupload.php
          c. csv-upload -> ajax-loader.gif
          d. csv-upload -> csv      //This the directory where csv file upload