Tuesday, 24 June 2014

how to upload multiple images in php mysql

<?php
if($_FILES['Enginimage']['name'])
{
 foreach ($_FILES['Enginimage']['name'] as $name => $value)
    {
$source=$_FILES['Enginimage']['tmp_name'][$name];
   $target='uploads/'.time().stripslashes($_FILES['Enginimage']['name'][$name]);
$image_name= 'Engin#'.time().stripslashes($_FILES['Enginimage']['name'][$name]);
if (copy($source,$target))
           {
      $time=time();
  $carid=session_id();
 $queryimage="INSERT INTO photo(carId,image_name,modified_date) VALUES('$carid','$image_name','$time')";
      mysql_query("$queryimage");
  }
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form method="post" id="EnginImage"  class="form-horizontal" enctype="multipart/form-data">
              <input type="file" name="Enginimage[]" multiple="true"/>
             <input type="submit" id="submited" name="submited" value="Image Upload"  />
            </form>
</body>
</html>

How to run database Query in WordPress?

<?php $wpdb->query('query'); ?>
// Examples
$wpdb->query(    "
    UPDATE $wpdb->posts
    SET post_parent = 7
    WHERE ID = 15
        AND post_status = 'static'    "
);

How to hide Directory Browsing in WordPress from server using .htaccess file?

Options -Indexes

How to hide the top admin bar at the frontend in WordPress

add_filter(‘show_admin_bar’, ‘__return_false’);

(or)
Add the below code in the active theme style.css stylesheet
#wpadminbar {
display: none; visibility: hidden;
}

Wednesday, 4 June 2014

Create testimonial custome function in wordpress

IN function.php

add_action('init', 'Testimonial');

function Testimonial() {

    $labels = array(
 'name' => _x('Testimonial', 'post type general name'),


'singular_name' => _x('Testimonial Item', 'post type singular name'),
        'add_new' => _x('Add New', 'Testimonial item'),
        'add_new_item' => __('Add New Testimonial Item'),
        'edit_item' => __('Edit Testimonial Item'),
        'new_item' => __('New Testimonial Item'),
        'view_item' => __('View Testimonial Item'),
        'search_items' => __('Search Testimonial'),
        'not_found' =>  __('Nothing found'),
        'not_found_in_trash' => __('Nothing found in Trash'),
        'parent_item_colon' => ''
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'show_ui' => true,
        'query_var' => true,
        'menu_icon' => admin_url(). 'images/testimonial.png',
        'rewrite' => true,
        'capability_type' => 'post',
        'hierarchical' => false,
        'menu_position' => null,
        'supports' => array('title','editor','thumbnail')
      );

    register_post_type( 'Testimonial' , $args );
}



In  front page you want to show testimonial

<div class="testimonial">
            <div class="testimonial_text">
                <span class="bottom_arrow"></span>
                <?php query_posts(array('showposts' => 1,'post_type' => 'Testimonial')); while (have_posts()) { the_post();
                    $pimage = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    ?>
                    <p><span><img src="<?php echo bloginfo('template_directory'); ?>/images/quot_img.png" alt="quot"></span><?php the_content(); ?> </p>
                    <?php } ?>
            </div>
            <div class="client_detail">
                <h4><strong>Pat Richie, Principal Consultant</strong><br>Table Group Consulting,</h4>
                <figure><img src="<?php echo bloginfo('template_directory'); ?>/images/client_img.png" alt="Client_1"></figure>
            </div>
        </div>

Tuesday, 3 June 2014

Create slider in wordpress

Function.php // write code  in function page

add_action( 'init', 'slider_home' );
function slider_home() {
    register_post_type( 'slider_home',
        array(
            'labels' => array(
                'name' => 'Slider',
                'singular_name' => 'Slider',
                'add_new' => 'Add New',
                'add_new_item' => 'Add New Slider',
                'edit' => 'Edit',
                'edit_item' => 'Edit Slider',
                'new_item' => 'New Slider',
                'view' => 'View',
                'view_item' => 'View Slider',
                'search_items' => 'Search Slider',
                'not_found' => 'No Slider found',
                'not_found_in_trash' => 'No Slider in Trash',
                'parent' => 'Parent Slider'
            ),

            'public' => true,
            'menu_position' => 15,
            'supports' => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields' ),
            'taxonomies' => array( '' ),
            'menu_icon' => admin_url( 'images/why_choose.png', __FILE__ ),
            'has_archive' => true
        )
    );
}


home page/ header.php // where you want to run slider

<ul>
     
        <?php $args = array('post_type' => 'slider_home' );
        $myposts = get_posts( $args );
       foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
          <li>
            <div class="slide-body" data-group="slide">
              <div class="container">
                <div class="wrapper">
                 <?php
                       
                        $slider1_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
                    
                        ?>
                  <div class="caption person" data-animate="slideAppearLeftToRight" data-delay="800"> <img src="<?php echo $slider1_image;  ?>" alt="Person"> </div>
                  <div class="caption problem_solved" data-animate="slideAppearLeftToRight">
                         
                       <?php echo $post->post_content; ?>
                        <a href="<?php the_permalink($post->ID); ?>">read more</a>
                  </div>
                 
                </div>
              </div>
            </div>
          </li>
          <?php endforeach;
          wp_reset_postdata();?>
         
        </ul>