Monday, May 21, 2012

wordpress Custom Post Types

By default, WordPress offers two different types of posts for content. First, you 
have the traditional “post”, used most often for what WordPress is known best for
 – blogging. Second, you have “pages”. Each of these, as far as WordPress is 
concerned, is a type of “post”. A custom post type is a type of post that you 
define. 

add_action('init', 'register_news, 1); // Set priority to avoid plugin conflicts
 
    function register_news() { // A unique name for our function
        $labels = array( // Used in the WordPress admin
                'name' => _x('News & Event', 'post type general name'),
                'singular_name' => _x('event', 'post type singular name'),
                'add_new' => _x('Add New', 'Event'),
                'add_new_item' => __('Add New Event'),
                'edit_item' => __('Edit Event'),
                'new_item' => __('New Event'),
                'view_item' => __('View Event '),
                'search_items' => __('Search Event'),
                'not_found' =>  __('Nothing found'),
                'not_found_in_trash' => __('Nothing found in Trash')
        );
        $file_dir=get_bloginfo('template_directory');
        $args = array(
                'labels' => $labels, // Set above
                'public' => true, // Make it publicly accessible
                'hierarchical' => false, // No parents and children here
                'menu_position' => 5, // Appear right below "Posts"
                'has_archive' => 'event', // Activate the archive
                'menu_icon' => $file_dir.'/images/faq.png',
                'supports' => array('title','author','editor','comments','thumbnail','custom-fields'),
        );
        
        register_taxonomy("catalog", array("event"), array("hierarchical" => true, "label" => "Categories", "singular_label" => "event", "rewrite" => true));
        register_post_type( 'event', $args ); // Create the post type, use options above
 }
?> 

Remove wordpress admin dashboard widgets






function pathshala_remove_dashboard_widgets() {

    // Globalize the metaboxes array, this holds all the widgets for wp-admin
     global $wp_meta_boxes;

    // Remove the incomming links widget
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);   
//$wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']
    // Remove right now
    unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
    //unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
    unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}

// Hoook into the 'wp_dashboard_setup' action to register our function
add_action('wp_dashboard_setup', 'pathshala_remove_dashboard_widgets' );

?>

Header Image Nivo Slider wp plugin


You can easily build a slider of your header images. This plugin also adds an option to remove your uploaded header images right from the Header options page.
As of now it only supports Nivo Slider.

Download: 
Header Image Slider

Thursday, May 10, 2012

Update data in wordpress table

$wpdb->update('wp_profile_visitor', array('count' => $countvisit, 'visitor_name' => $final_current_user->display_name), array('profile_id' =>$final_curauth->ID, 'visitor_id' =>$final_current_user->ID ));

wp_profile_visitor is table name.
array('count' => $countvisit, 'visitor_name' => $final_current_user->display_name) is updated data and
array('profile_id' =>$final_curauth->ID, 'visitor_id' =>$final_current_user->ID ) where condition.
 



Insert data in wordpress table

$wpdb->insert('wp_profile_visitor', array(
            'profile_id' => $final_curauth->ID,
            'visitor_id' => $final_current_user->ID,
            'visitor_name' => $final_current_user->display_name,
            'visitor_nicename' => $final_current_user->user_nicename,           
            ) );
"wp_profile_visitor" is table name
"profile_id" is table field name and $final_curauth->ID is dynamic data..

You can also insert in  another format. I have given a example please see  http://h20bikash.blogspot.com/2012/05/inserting-into-data-in-wordpress.html


Sunday, May 6, 2012

Inserting Into Data in WordPress database

To perform an insert, we can use the insert method: 
 $wpdb->$wpdb->insert( $table, $data, $format ); ?> 
 Insert a row into a table.
$wpdb->insert(
'rz_tblsubmit',
array(
'id' => '',
'titleofevent' => $_POST["title"],
'typeofevent' => $_POST["type"],
'organisation' => $_POST["organisation"],
'website' => $_POST["website"],
'description' => $_POST["description"],
'startdate' => $_POST["start_date"]."-".$_POST["start_time"],
'enddate' => $_POST["end_date"],
'entryprice' => $_POST["entry_price"],
'venueaddress' => $_POST["venue_address"],
'venuecountry' => $_POST["venue_country"],
'postcode' => $_POST["venue_postcode"],
'venuewebsite' => $_POST["venue_website"],
'contact' => $_POST["contact"],
'contactemail' => $_POST["contact_email"],
'contactphone' => $_POST["contact_phone"],
'wessage' => $_POST["message"],

),
array(
'',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%s',
'%d',
'%s',
'%s',
'%s',
'%d',
'%s'

)
); ?>

Saturday, May 5, 2012

wordpress upload http error...!!!

function push_the_max(){
@ini_set( 'upload_max_size' , '100M' );
@ini_set( 'post_max_size', '105M');
@ini_set( 'max_execution_time', '300' );
}
add_action('init','push_the_max');