Showing posts with label wordpress. Show all posts
Showing posts with label wordpress. Show all posts

Wednesday, 19 July 2017

Get posts using wordpress rss feed url and add featured post thumbnails in WordPress feeds

Get posts using wordpress rss feed url and add featured post thumbnails in WordPress feeds


here the example of geting data from rss feed url

this code in your current wordpress function.php file 
// display featured post thumbnails in WordPress feeds
function wcs_post_thumbnails_in_feeds( $content ) {
    global $post;
    if( has_post_thumbnail( $post->ID ) ) {
        $content = '<p>' . get_the_post_thumbnail( $post->ID ) . '</p>' . $content;
    return $content;
add_filter( 'the_excerpt_rss', 'wcs_post_thumbnails_in_feeds' );
add_filter( 'the_content_feed', 'wcs_post_thumbnails_in_feeds' );

$url = 'Your Wordpress Rss Fedd';

    $rss = new DOMDocument();
    $feed = array();
    foreach ($rss->getElementsByTagName('item') as $node) {
        $item = array (
                'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
                'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
                'pubDate' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
                'description' => $node->getElementsByTagName('description')->item(0)->nodeValue,
                'content' => $node->getElementsByTagName('encoded')->item(0)->nodeValue

       array_push($feed, $item);

foreach($feed as $f){
preg_match('/<img.+src=[\'"](?P<src>.+?)[\'"].*>/i', $f['description'], $image);

   $content = strip_tags(preg_replace("/<img[^>]+\>/i", "", $image[0]),"</p>");
$pos = strrpos( $content, '[');
echo  $image['src']; // Get Feature image in rss
echo $f['link']; // Get Link in post
echo $f['title']; // get Title of post
echo $f['pubDate']; // get Publish date
echo rtrim (substr($content, 0, $pos) ); // Only get description


Tuesday, 26 April 2016

Read More link in blog in php and Wordpress using Jquery

Read More link  in blog in php and Wordpress using Jquery

<script src=""></script>
<script type="application/javascript">
jQuery(document).ready(function($) {


var href = jQuery(this).text();
if(href=="read more..."){

var moretext =jQuery(this).parent().parent().find('input[name=more]').val();


var lesstext =jQuery(this).parent().parent().find('input[name=less]').val();

return false;


$string="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
<div class="product_text">
<?php   $string = strip_tags($string)." <a class='less' href='javascript:void(0)'>less</a>";
$substr = substr($string, 0, strpos(wordwrap($string, 250), "\n"))." <a class='less' href='javascript:void(0)'>read more...</a>";
                <input type="hidden" name="less" value="<?php echo $substr; ?>" />
                <input type="hidden" name="more" value="<?php echo $string; ?>" />


echo '<p class="readMore">'.$substr."</p>";



Wednesday, 30 March 2016

Custom Url ReWrite in Wordpress

here Example How To generate custom url rewrite in wordpress

Check it

function create_custom_rewrite_rules() {
global $wp_rewrite;

$rewrite_tag = '%patentID%';
$wp_rewrite->add_rewrite_tag( $rewrite_tag, '(.+?)', 'patentID=' );
$rewrite_keywords_structure = $wp_rewrite->root . "%pagename%/$rewrite_tag/";
$new_rule = $wp_rewrite->generate_rewrite_rules( $rewrite_keywords_structure );

$wp_rewrite->rules = $new_rule + $wp_rewrite->rules;

return $wp_rewrite->rules;

function add_custom_page_variables( $public_query_vars ) {
$public_query_vars[] = 'patentID';

return $public_query_vars;


function flush_rewrite_rules132() {

global $wp_rewrite;



add_action( 'init', 'flush_rewrite_rules132' );
add_action( 'generate_rewrite_rules', 'create_custom_rewrite_rules' );
add_filter( 'query_vars', 'add_custom_page_variables' );

You can get this using

$patentID = get_query_var('patentID');  in you template

Wednesday, 16 March 2016

Insert custom post data with custom field using ajax in wordpress

Insert custom post data  with custom field using ajax in wordpress

<!-- This code in your custom template -->

 jQuery(document).ready(function() {
var form = jQuery( "#newCustomerForm" );


  var  checkForm = form.valid();
  if(checkForm != false){

var newCustomerForm = jQuery('#newCustomerForm').serializeArray();
url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
data: newCustomerForm,
success: function(data){

if(data == "success"){


return false;
<form name="test" id="newCustomerForm">
                              <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-user"></i></span>
                              <input  class="form-control" type="text" placeholder="Enter your name" name="alu_name" required="required" />
                              <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-envelope-o"></i></span>
                                <input id="exampleInputEmail1" class="form-control" type="email" placeholder="Enter your Email" name="alu_email" required="required" />
                                <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-mobile"></i></span>
                                <input  class="form-control" type="number" placeholder="Enter your Mobile no" name="alu_mobile" required="required" />
                                <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-university"></i></span>
                                <input  class="form-control" type="text" placeholder="Enter your city name" name="alu_city" required="required" />
                                <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-commenting"></i></span>
                                <textarea id="exampleTextarea" class="form-control" rows="3" name="alu_message" required="required"></textarea>
                                <button type="button" class="btn primary alu1">Submit</button>
                                 <input type="hidden" name="submitted" id="submitted" value="true" />
    <input type="hidden" name="nonce" value="<?php echo wp_create_nonce( 'form-nonce' );?>" />  
                            <input type="hidden" name="action" id="my_action" value="my_action" />                   

/** In Your Function File **/
              function myFunction(){
   //do something

$alu_name=    sanitize_meta('name_alu_c1',$_POST['alu_name'],'user');
$alu_email=    sanitize_email($_POST['alu_email']);
$alu_mobile=    sanitize_meta('phone_alu_c1',$_POST['alu_mobile'],'user');
$alu_city=    sanitize_meta('city_alu_c1',$_POST['alu_city'],'user');
$alu_message=    sanitize_meta('message_alu_c1',$_POST['alu_message'],'user');

$my_cptpost_args = array(
            'post_title' => $alu_name,
            'post_status'   => 'publish',
            'post_type' => "alu_contact1",
$cpt_id = wp_insert_post($my_cptpost_args, $wp_error );
add_post_meta($cpt_id, 'name_alu_c1', $alu_name, true);//here insert two custom field data.
add_post_meta($cpt_id, 'email_address_alu_c1', $alu_email, true);//here insert two custom field data.
add_post_meta($cpt_id, 'phone_alu_c1', $alu_mobile, true);//here insert two custom field data.
add_post_meta($cpt_id, 'city_alu_c1', $alu_city, true); //here insert two custom field data..
add_post_meta($cpt_id, 'message_alu_c1', $alu_message, true); //here insert two custom field data..

$test = wp_mail( $alu_email, "Contact Us", "Thank You For Contact us" );

echo "success";

add_action('wp_ajax_my_action', 'myFunction');           // for logged in user
add_action('wp_ajax_nopriv_my_action', 'myFunction');    // if user not logged in  

Sunday, 13 March 2016

how to add custom column in wordpress categoty or texonomy admin panel in wordpress

how to add custom column in wordpress categoty or texonomy admin panel in wordpress

// product-category is my custom category change your texonomy
add_filter("manage_edit-product-category_columns", 'theme_columns');

function theme_columns($theme_columns) {
    $new_columns = array(
        'cb' => '<input type="checkbox" />',
        'name' => __('Name'),
        'category' => 'Category Banner',
      'description' => __('Description'),
        'slug' => __('Slug'),
        'posts' => __('Posts')
    return $new_columns;

add_filter("manage_product-category_custom_column", 'manage_theme_columns', 10, 3);

function manage_theme_columns($out, $column_name, $theme_id) {
    $theme = get_term($theme_id, 'product-category');

global $post;

    switch ($column_name) {
        case 'category':
            // get header image url

           $variable = get_field( 'category_image', 'product-category_'.$theme_id );//here advace customfield value you can use your custom field;
            $out .= "<img src=".$variable." height='83px' width='150px'/>";

    return $out;   

How to chnage character lenght and continue reading text in excerpt in wordpress

How to chnage character lenght and continue reading text in excerpt in wordpress

if you have child theme first remove this filter  i have twenty thierteen theme

function child_theme_setup() {
// override parent theme's 'more' text for excerpts
remove_filter( 'excerpt_more', 'twentythirteen_excerpt_more' );

add_action( 'after_setup_theme', 'child_theme_setup' );

after change character lenght in wordpress

function et_excerpt_length($length) {
    return 70;
add_filter('excerpt_length', 'et_excerpt_length');

you can change the text of continue reading

function et_excerpt_more($more) {
    global $post;
    return '<a href="'. get_permalink($post->ID) . '" class="view-full-post-btn"> read more....</a>';
add_filter('excerpt_more', 'et_excerpt_more');

Monday, 4 January 2016

Customize single product page in woocommerce

All function call in wc-template-function.php file check it
location is woocommerce/include/
if you change position of product title,single rating,single price,description,add to cart then

follow below code.

go to content-single.php file

<div class="summary entry-summary">

* woocommerce_single_product_summary hook
* @hooked woocommerce_template_single_title - 5
* @hooked woocommerce_template_single_rating - 10
* @hooked woocommerce_template_single_price - 10
* @hooked woocommerce_template_single_excerpt - 20
* @hooked woocommerce_template_single_add_to_cart - 30
* @hooked woocommerce_template_single_meta - 40
* @hooked woocommerce_template_single_sharing - 50
//do_action( 'woocommerce_single_product_summary' );

             woocommerce_template_single_price(); // this will output the price text
             woocommerce_template_single_excerpt(); // this will output the short description of your product.

</div><!-- .summary -->

here all get single single you can set in your html

if you want to change breadcub then go to single-product file

follow below


//do_action( 'woocommerce_before_main_content' );

this and

this two funcion


set it your ways

Sunday, 16 August 2015

Insert Post Data FrontEnd side with Custom Field and Validation in Wordpress


First create template file in in your wordpress theme.

<?php /* Template Name: Account*/ ?>

after go to pages in wordpress create page in  your page and set template Account in wordpress.

after go to your post when you added insert data in frond end side. go to screen option
and checked custom fields.

here I am create email address,first name,last name,and phone.

you can also inset data in texonomy.

<?php /* Template Name: Account */

get_header(); ?>
<script src="//"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
        dateFormat : 'yy-mm-dd'
        // Specify the validation rules
        rules: {
            f_name: "required",
            l_name: "required",
            email: {
                required: true,
                email: true
                 equalTo: '#email'
                 required: true,
                date: true
             center_term: {
                required: true,
            casetype: {
                required: true,
        // Specify the validation error messages
        messages: {
            f_name: "Please enter your first name",
            l_name: "Please enter your last name",
            email: "Please enter a valid email address",
                required:"Please enter date",
                date:"Please validate date"
            phone:"Please enter Phone Number",
            center_term:"Please select the center",
            casetype:"Please Select Reson for visist",
            c_email:"Please Conform Email Address"
        submitHandler: function(form) {
    jQuery('#appoment_date').change(function () {alert('changed');
    if (document.getElementById("appoment_date").value === "") {
    } else {

<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">

// Start the loop.
while ( have_posts() ) : the_post();

// Include the page content template.
get_template_part( 'content', 'page' );

// If comments are open or we have at least one comment, load up the comment template.
if ( comments_open() || get_comments_number() ) :

// End the loop.
        <form method="post" id="appmoment_form">
        <?php $terms = $categories = get_terms( 'your-custom-texonomy', 'orderby=count&hide_empty=0' ); ?>
        <select name="center_term" id="center_term">
        <option value="">Select a Center</option>
      <?php   foreach ( $terms as $term ) { ?>
        <option value="<?php echo $term->name ?>"><?php echo $term->name ?></option>
        <?php } ?>
      <input type="text" id="appoment_date" name="appoment_date" placeholder="Select a date" />
      <select name="time_appoment" id="time_appoment" disabled="disabled">
      <option>Select a Available Time</option>
      <option value="12PM to 1 AM">12PM to 1 AM</option>
      <option value="">1PM to 2 AM</option>
      <option value="">2PM to 3 AM</option>
      <option>3PM to 4 AM</option>
      <option>4PM to 5 AM</option>
      <option>5PM to 6 AM</option>
      <option>6PM to 7 AM</option>
      <option>7PM to 8 AM</option>
      <option>8PM to 9 AM</option>
      <input type="text" name="f_name" id="f_name" placeholder="First Name" />
      <input type="text" name="l_name" id="l_name" placeholder="Last Name" />
      <input type="text" name="email" id="email" placeholder="Email Address" />
      <input type="text" name="c_email" id="" placeholder="Conform Email Address" />
      <input type="text" name="phone" id="phone" placeholder="Phone" />
      <?php $texonomys1 = $categories = get_terms( 'your-custom-texonomy', 'orderby=count&hide_empty=0' ); ?>
      <select name="casetype" id="casetype">
      <option value="">Reason for Visit</option>
      <?php   foreach ( $texonomys1 as $texonomy1 ) { ?>
       <option value="<?php echo $texonomy1->name ?>"><?php echo $texonomy1->name ?></option>
       <?php } ?>
      <input type="submit" name="submit" />
       if (isset( $_POST['submit'] ) ) {
// create post object with the form values
                    $appoment_date =    $_POST['appoment_date'];
                    echo $appoment_date;
                    $firstname = $_POST['f_name'];
                    $lastname = $_POST['l_name'];
                    $email_address = $_POST['email'];
                    $phone = $_POST['phone'];
                    $term = $_POST['center_term'];
                    $texonomy1 = $_POST['casetype'];

        $my_cptpost_args = array(
            'post_title' => 'test',
            'post_status'   => 'publish',
            'post_type' => "pgs_appointments",
            'post_date' => $appoment_date,
            'tax_input'    => array( 'your-custom-texonomy' => array( $texonomy1 ),'your-custom-texonomy' => array( $term ) ) //here insert two texonomy data.
        $email_address = sanitize_email($email_address);
        $first_name = sanitize_meta( 'first_name', $first_name, 'user' );
        $lastname = sanitize_meta( 'lastname', $lastname, 'user' );
        $email_address = sanitize_meta( 'email_address', $email_address, 'user' );
        $phone = sanitize_meta( 'phone', $phone, 'user' );

// insert the post into the database
            $cpt_id = wp_insert_post($my_cptpost_args, $wp_error );
         add_post_meta($cpt_id, 'first_name', $first_name, true);//here insert two custom field data.
         add_post_meta($cpt_id, 'email_address', $email_address, true);//here insert two custom field data.
         add_post_meta($cpt_id, 'lastname', $lastname, true); //here insert two custom field data..
         add_post_meta($cpt_id, 'phone', $phone, true);//here insert two custom field data.
</main><!-- .site-main -->
</div><!-- .content-area -->

<?php get_footer(); ?>

Monday, 27 July 2015

Order By Custom Field Using Meta Key In Wordpress


Order By Custom Field Using Meta Key In Wordpress

In some case you can to get post value using meta box in order by ascending order and descending order


$dancequery = array('post_type'=> 'dance',
'tax_query' => array(
array('taxonomy' => 'hip_hop','field' => 'id','terms' =>'hip_hop',),
'post_status' => 'publish',
'paged' => $paged ,
'meta_key' => 'price',
'orderby' => 'meta_value_num',
'order' => 'DESC'
query_posts( $dancequery );


if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

  • check this type code. price yon can add your meta key create in post.
    i am also give example with taxonomy you can get value form particular taxonomy and particular
    meta key order by i have meta key price.

    it's working proper check out.

    Monday, 20 July 2015

    How To Create Wordpress Theme


    Here I want Create Example of Wordpress theme.

    You want to create your own wordpress theme then you can know create basic file.

    3)style.css //Most Impotant
    5)sidebar.php //optional
    6)functions.php // optional

    this 6 file needed for custom theme in Wordpress

     I am Create Wordpress Theme My Own I give Example for that you can change and
    and create your own.

    1) header.php

    <title><?php bloginfo('name'); ?></title>
    <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>"/>
    <div id="wrapper">
    <div id="header">
    <a id="logo"href="<?php echo site_url(); ?>"><h1><?php bloginfo('name'); ?></h1></a>

    <img id="header_image" src="<?php header_image(); ?>" height="<?php echo get_custom_header()->height; ?>" width="<?php echo get_custom_header()->width; ?>" alt="" />

      <?php wp_nav_menu(); ?>



    <div id="footer">
    <?php if (  dynamic_sidebar( 'widgetized-area' ) ) : ?>
    <?php endif; ?>


    <div id="sidebar">
    <?php if (  dynamic_sidebar( 'footer-id' ) ) : ?>
    <?php endif; ?>

    4) index.php

    <?php get_header(); ?>
    <div id="main">
    <div id="content">
    <h1>Main Area</h1>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <h1><?php the_title(); ?></h1>
    <h4>Posted on <?php the_time('F jS, Y') ?></h4>
    <p><?php the_content(__('(more...)')); ?></p>
    <hr> <?php endwhile; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p><?php endif; ?>
    <?php get_sidebar(); ?>
    <div id="delimiter">
    <?php get_footer(); ?>


    $args = array(
    'width'         => 980,
    'height'        => 198,
    'default-image' => get_template_directory_uri() . '/images/header.jpg',
    add_theme_support( 'custom-header', $args );

    function register_my_menu() {
      register_nav_menu('header-menu',__( 'Header Menu' ));
    add_action( 'init', 'register_my_menu' );

    if (function_exists('register_sidebar')) {

    'name' => 'Widgetized Area',
    'id'   => 'widgetized-area',
    'description'   => 'This is a widgetized area.',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget'  => '</div>',
    'before_title'  => '<h4>',
    'after_title'   => '</h4>'
    'name' => 'Footer',
    'id'   => 'footer-id',
    'description'   => 'This is a widgetized area for Footer.',
    'before_widget' => '<div id="%1$s" class="widget %2$s">',
    'after_widget'  => '</div>',
    'before_title'  => '<h4>',
    'after_title'   => '</h4>'



    body { text-align: center; }
    #wrapper { display: block; border: 1px #a2a2a2 solid; width:90%; margin:0px auto; }
    #header { border: 2px #a2a2a2 solid; width:1196px; height:296px;}
    #content { width: 75%; border: 2px #a2a2a2 solid; float: left; }
    #sidebar { width: 23%; border: 2px #a2a2a2 solid; float: right; }
    #delimiter { clear: both; }
    #footer { border: 2px #a2a2a2 solid;width:1196px; height:296px; }
    .title { font-size: 11pt; font-family: verdana; font-weight: bold; }
        float: left;
        position: absolute;
        color: #fff;
    .menu-menu-1-container li {
        display: inline-block;
        margin: 10px;
    .widget_nav_menu li{
        display: block;
    .widget_categories li{
        list-style: none;
    #footer .widget_nav_menu{
        float: left;
    #footer .widget_categories{
        float: none;

    In functions.php file I create code for Add Menu:- register_my_menu FUNCTION


    Wednesday, 1 July 2015

    Get Post Title or Post Permalink using Post Name in Wordpress


    You can get post title and permalink any one you want from post it easy to get this.

    I have one example post that can be useful that.

    you can also also use in search. and simple any where in wordpress.

    Simple Get Wordpress.

    $city_name = array("Bab Ezzouar","Babol","Babruysk","Bago City");

    foreach($city_name as $city){
     echo $city;
    $posts = get_posts(array('name' => $city, 'post_type' => 'your-postname-here','post_status'=>'publish'));

    foreach ($posts as $post) {
      echo $title = get_the_title($post->ID);
      echo    $permalink = get_permalink($post->ID);

        break; //use this to limit to a single result

    check out your wordpress. cityname enter your post name and post type check out result

    Monday, 22 June 2015

    How To Add Taxonomy In Multiple Post In Wordpress


    Some Time Same Taxonomy use in multiple post. for example onw taxonomy like music

    I Want to use multiple post like WordPress default post,musician,or another post.

    I have Solution for that check below code

    register_taxonomy('music',array('musician','post','page'), array(
        'hierarchical' => true,
        'labels' => $labels,
        'show_ui' => true,
        'query_var' => true,
        'rewrite' => array( 'slug' => 'music' ),

    here  music is your taxonomy name. in your array add your post i have added post,musician,page etc

    this code add to your theme in function.php or plugin file.

    that can be worked

    Friday, 19 June 2015

    Wp Query Get Child Post Or Page Of Current Page Or Post In Wordpress(Parent Post)


    I am Giving example of how to get  parent post of child post or page.

    I have top market post type. i am create child post in this i have code to get child post of current parent post.

      $args = array(
        'post_type'      => 'top_markets',
        'posts_per_page' => -1,
        'post_parent'    => $post->ID,
        'order'          => 'ASC',
        'orderby'        => 'menu_order'

    $parent = new WP_Query( $args );

    if ( $parent->have_posts() ) : ?>

        <?php while ( $parent->have_posts() ) : $parent->the_post(); ?>

            <div id="parent-<?php the_ID(); ?>" class="parent-page">

                <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>


        <?php endwhile; ?>

    <?php endif; wp_reset_query(); ?>

    if you to want current page child page in wordpres check this code in your template file.

    $args = array(
        'post_type'      => 'page',
        'posts_per_page' => -1,
        'post_parent'    => $post->ID,
        'order'          => 'ASC',
        'orderby'        => 'menu_order'

    $parent = new WP_Query( $args );

    if ( $parent->have_posts() ) : ?>

        <?php while ( $parent->have_posts() ) : $parent->the_post(); ?>

            <div id="parent-<?php the_ID(); ?>" class="parent-page">

                <h1><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h1>


        <?php endwhile; ?>

    <?php endif; wp_reset_query(); ?>

    Thursday, 11 June 2015

    Create Simple Text With Image Widget In Wordpress

    Hell All,

    I am have simple text widget With image. you can upload image and you can add link on
    image you can add class and id on image also you can add height and width in widget.

    Please Check My Widget Image you can understand that.

    I am create plugin for it. in pluun in folder => create folder myWidget => create file
    =>myWidget .php and same folder create js file => upload-media.js

    after you can check code in file

    in myWidget .php file add this code

    * Plugin Name: My Widget
    * Plugin URI:
    * Description: This plugin for widget.
    * Version: 1.0.0
    * Author: jaydisinh Parmar
    * Author URI:
    function ctUp_wdScript(){

                    wp_enqueue_script('upload_media_widget', plugin_dir_url(__FILE__) . 'upload-media.js', array('jquery'));
            add_action('admin_enqueue_scripts', 'ctUp_wdScript');
                    function my_admin_styles() {

    add_action('admin_print_styles', 'my_admin_styles');


    class My_Widget extends WP_Widget {
        function __construct() {
    'my_widget', // Base ID
    __( 'A Text Widget', 'text_domain' ), // Name
    array( 'description' => __( 'Just Text Widget', 'text_domain' ), ) // Args
        public function widget( $args, $instance ) {
            echo $args['before_widget'];
            if ( ! empty( $instance['title'] ) ) {
    echo $args['before_title'] . apply_filters( 'widget_title', $instance['title'] ). $args['after_title'];
    echo __( 'Hello, World! HappY', 'text_domain' );  
            if ( ! empty( $instance['desc'] ) ) {
    echo $args['before_title'] .$instance['desc']. $args['after_title'];
            if ( ! empty( $instance['height'] ) ) {
                $height = $instance['height'];
                    $height = "300";
                if ( ! empty( $instance['width'] ) ) {
                $width = $instance['width'];
                    $width = "300";
                if ( ! empty( $instance['link_url'] ) ) {
                $link_url = $instance['link_url'];
             if ( ! empty( $instance['image'] ) ) {
                echo $args['before_title'];?>
    <?php if($link_url){ ?><a href="<?php echo $link_url; ?>"><?php } ?><img src="<?php echo  $instance['image']?>" height="<?php echo  $height; ?>" width="<?php echo  $width; ?>" class="<?php echo  $instance['image_class']?>" id="<?php echo  $instance['image_id']?>" /><?php if($link_url){ ?></a><?php } ?>
                <?php $args['after_title'];
        public function form( $instance ) {
            $title = ! empty( $instance['title'] ) ? $instance['title'] : __( 'New title', 'text_domain' );
            $desc = ! empty( $instance['desc'] ) ? $instance['desc'] : '';
            $image = ! empty( $instance['image'] ) ? $instance['image'] : '';
            $link_url = ! empty( $instance['link_url'] ) ? $instance['link_url'] : '';
            $height = ! empty( $instance['height'] ) ? $instance['height'] : '';
            $width = ! empty( $instance['width'] ) ? $instance['width'] : '';
            $image_id = ! empty( $instance['image_id'] ) ? $instance['image_id'] : '';
            $image_class = ! empty( $instance['image_class'] ) ? $instance['image_class'] : '';
    <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>"/>
    <label for="<?php echo $this->get_field_id( 'DeScription' ); ?>"><?php _e( 'DeScription:' ); ?></label> 
    <textarea class="widefat" id="<?php echo $this->get_field_id( 'desc' ); ?>" name="<?php echo $this->get_field_name( 'desc' ); ?>"><?php echo esc_attr( $desc ); ?></textarea>
    <label for="<?php echo $this->get_field_id( 'link_url' ); ?>"><?php _e( 'On Image Link Url:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'link_url' ); ?>" name="<?php echo $this->get_field_name( 'link_url' ); ?>" type="text" value="<?php echo esc_attr( $link_url ); ?>"/>
    <label for="<?php echo $this->get_field_id( 'height' ); ?>"><?php _e( 'Image Height:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'height' ); ?>" name="<?php echo $this->get_field_name( 'height' ); ?>" type="text" value="<?php echo esc_attr( $height ); ?>"/>
    <label for="<?php echo $this->get_field_id( 'width' ); ?>"><?php _e( 'Image Width:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'width' ); ?>" name="<?php echo $this->get_field_name( 'width' ); ?>" type="text" value="<?php echo esc_attr( $width ); ?>"/>
    <label for="<?php echo $this->get_field_id( 'image_id' ); ?>"><?php _e( 'Image ID:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'image_id' ); ?>" name="<?php echo $this->get_field_name( 'image_id' ); ?>" type="text" value="<?php echo esc_attr( $image_id ); ?>"/>
    <label for="<?php echo $this->get_field_id( 'image_class' ); ?>"><?php _e( 'Image Calss:' ); ?></label> 
    <input class="widefat" id="<?php echo $this->get_field_id( 'image_class' ); ?>" name="<?php echo $this->get_field_name( 'image_class' ); ?>" type="text" value="<?php echo esc_attr( $image_id ); ?>"/>
               <input name="image" class="my_upload_image_button" type="button" value="Upload"/>
               <input class="widefat upload_image" id="<?php echo $this->get_field_id( 'image' ); ?>" name="<?php echo $this->get_field_name( 'image' ); ?>" type="text" value="<?php echo esc_attr( $image ); ?>" readonly=""/>
               <?php if(!empty($image)){ ?>
               <img src="<?php echo esc_attr( $image ); ?>" height="100" width="100" />
               <?php } ?>
            public function update( $new_instance, $old_instance ) {
    $instance = array();
    $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
            $instance['desc'] = ( ! empty( $new_instance['desc'] ) ) ? ( $new_instance['desc'] ) : '';
            $instance['image'] = ( ! empty( $new_instance['image'] ) ) ? ( $new_instance['image'] ) : '';
            $instance['link_url'] = ( ! empty( $new_instance['link_url'] ) ) ? ( $new_instance['link_url'] ) : '';
            $instance['height'] = ( ! empty( $new_instance['height'] ) ) ? ( $new_instance['height'] ) : '';
            $instance['width'] = ( ! empty( $new_instance['width'] ) ) ? ( $new_instance['width'] ) : '';
            $instance['image_id'] = ( ! empty( $new_instance['image_id'] ) ) ? ( $new_instance['image_id'] ) : '';
            $instance['image_class'] = ( ! empty( $new_instance['image_class'] ) ) ? ( $new_instance['image_class'] ) : '';

    return $instance;


    add_action( 'widgets_init', function(){
         register_widget( 'My_Widget' );


    after in your upload-media.js file add this code

    jQuery(document).ready(function($) {
      $(document).on("click", ".my_upload_image_button", function() { 

    window.send_to_editor = function(html) {
    imgurl = jQuery('img',html).attr('src');


    tb_show('', 'media-upload.php?type=image&TB_iframe=true');
    return false;

    after this active plugin in My Widget. go to Appearance and check the in widgets => check
    A Text Widget add in sidebar.

    Tuesday, 2 June 2015

    Create Child Theme Of Wordpress Theme And Create Template In Wordpress

    Hello All,

    Here Simple Create Child theme in wordpss and how to create template in Wordpress.
    Here I see the example of make child theme twentythirteen. same step use you can
    create any of theme child theme.

    Use Of child theme.

    Child theme very usefull. because some time theme have update. we can update it theme
    then you can change stucture is removed. but you can make child theme can be usefull.

    Simple Follow Step you can create child theme in wordpress Easily.

    First Goto Wordpress Theme Folder.=>/wp-content/themes/
    Then Create child Theme Like I am Create thirteenchild Folder.

    Here Simple create style.css and add the below code.

    Theme Name:     twentythirteenchild
    Theme URI:
    Author:         coder
    Author URI:
    Template:       twentythirteen
    Version:        0.1

    @import url("../twentythirteen/style.css");

    After login your dashboard (wordpress Admin) 
    Go To :=> Appearance > Themes
    and active your theme child theme. here theme name is twentythirteenchild.

    Second How to create template in wordpress.

    you want to create template. you just copy page.php file or create new page 

    if you want to create page template it's better to copy page.php file. 

    Step2 : 

    page.php ot new page add below code in header.

    <?php /* Template Name: My Custom Page */ ?>

    check it wp-admin page=>edit or new page you can see On the right hand side under attributes you’ll see template.

    Sunday, 17 May 2015

    Remove Image Title In Wordpress

    Hello All,

    Some Time you have requirement to remove image title in wordpress site.
    but you added lots of image and also if you can change manully then it so
    long work.

    when yon remove image title  content. you can use this code and check it.

    it's only change when you added image in wordpress editor. but when you can
    create plugin on use any plugin in when added image title that can not remove that.
    there you can use simple Jquery

    Use  AnD Remove Image Title In Content Filter check below code.

    This code added in you current theme functions.php also you can create plguin for it

    add_filter('the_content', 'remove_images_titles');
    function remove_images_titles($text) {
        // Get all title="..." tags from the html.
        $result = array();
        preg_match_all('|title="[^"]*"|U', $text, $result);
        // Replace all occurances with an empty string.
        foreach($result[0] as $img_tag) {
            $text = str_replace($img_tag, '', $text);
        return $text;
    But you can remove image title in all wordpress site follow simple jquery and 
    check result
    jQuery(document).ready(function($) {
    this code added in your header.php after added all script in wrdpress.
    refresh your site check it using firebug it can be remove image title.
    please tell me this can be helpfull or not? comment Please?

    Thursday, 7 May 2015

    Contact form in Wordpress

    Contact form in Wordpress

    Hello  All,

    Mostly Use Contact Form In Web site.

    I am Create simple code  for add contact form in wordpress.

    It's Only Example No Plugin required. You can also Custimise;

    I am create Name,Email,Message Fild in wordpress;

    CREATE TABLE IF NOT EXISTS `wp_myphpinformation` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `name` varchar(100) NOT NULL,
      `email` varchar(100) NOT NULL,
      `message` varchar(225) NOT NULL,
      PRIMARY KEY (`id`)

    I am create this table in my php admin.

    Create templete In Wordpress

    Template Name: My Custom Page

    Copy the page.php of your current theme and change name like contactform.php

    After adding a comment and check with your admin this template.

    I am here add full Ecample Code Check IT. I hope you like;

    it's contactform.php


    Template Name: My Custom Page
    <?php get_header(); ?>
            if (!empty($_POST)) {
            global $wpdb;
                $table = wp_myphpinformation;
                $data = array(
                    'name' => $_POST['yourname'],
                    'email'    => $_POST['email'],
                    'message' =>  $_POST['message']
                $format = array(
                $success=$wpdb->insert( $table, $data, $format );
                echo 'data has been save' ; 
    else   {
            <form method="post">

    Contact Me

            <input type="text" name="yourname"/><br />
            <input type="text" name="email"/><br />
            <textarea name="message"></textarea><br />//textarea code
            <input type="submit"/>

           <?php }  ?>
           <div class="contact">
           $results = $wpdb->get_results( 'SELECT * FROM wp_myphpinformation', OBJECT );
           foreach($results as $result){?>
            <td>php echo $result->name; ?></td>
            <td>php echo $result->email; ?></td>
            <td>php echo $result->message; ?></td>
          <?php }

    <?php get_footer(); ?>

    Wednesday, 1 April 2015

    How to add custom sidebar in wordpress

    How to add custom sidebar in wordpress


    Here Example of add custom sidebar in wordpress

    please check it below code.

    here example to add custom sidebar.

    function theme_slug_widgets_init() {

    register_sidebar( array(
            'name' => __( 'Header Sidebar', 'theme-slug' ),
            'id' => 'home-header-1',
            'description' => __( 'Widgets in this area will be shown on all posts and pages.', 'theme-slug' ),
            'before_title' => '


            'after_title' => '
        ) );

    add_action( 'widgets_init', 'theme_slug_widgets_init' );

    here to add custom sidebar in wordpress
    name : you can add your sidebar name
    id : it can use to uniq and call siderbar in wordpress
    description: it can be what can be added in siderbar 
    and what to add for this just description for end user
    knowledge where to add this sidebar
    before_title and after title: here name display h1 tag in you can change in tag. or html of before title and after title.

    if you want to add this siderbar check below code

    if ( is_active_sidebar( 'home-header-1' ) ) : 
     dynamic_sidebar( 'home-header-1' )

    here dynamic_sidebar add siderbar id if sidebar is active then
    it will call