Showing posts with label Wordpress. Show all posts
Showing posts with label Wordpress. Show all posts

October 22, 2020

Woocommerce: checkout form remove label and add placeholder

 

checkout form remove label and add placeholder


- Woocommerce allow you to remove any property of $field->property by using unset,

- Reference can be here: Customizing checkout fields using actions and filters,

- Here simple example of checkout form remove label and add placeholder,


e.g:

add_filter('woocommerce_checkout_fields','wc_checkout_fields_remove_callback');

function wc_checkout_fields_remove_callback($fields) {

    foreach ($fields as $cat => $value) {

        foreach ($fields[$cat] as $field => $prop) {

            unset($fields[$cat][$field]['label']);

        }

    }

   return $fields;

}


Enjoy!

December 9, 2018

How to post a blog from wordpress admin?

   
      Basically wordpress used for blog posting for any business. Its very easily so non technical person can post blogs with content, images and video also. Here I try to explain how to post a blog from wordpress in easy way.

     If you new for wordpress please follow my previous post to download and install latest version of wordpress on localhost system using xampp.


Step: 1

- Login in your wordpress admin using username/password and you can see admin dashboard and left side menu for posts.

- First you need to create category for different type of posts. You need to enter category name, slug name and select parent category if needed.



Step: 2

- When you click on All Posts its display list of all posts with Edit, Trash and View option, So you can easily edit and view any post


Step: 3

- Now for add new post you have following basic options:

- Title
- Full Description
- Short Description(Excerpt)
- Tags
- Select Category
- Set Featured Image


Step: 4

- At last Publish post and view your blog preview on front end side

I hope this post is help for post blog in wordpress.

Enjoy!

December 1, 2018

How to download and install latest version of wordpress on localhost syste usgin xampp?

Step: 1
  - First you need to Download XAMPP and install in your local sysmte.

   - Now you need to Download latest version of Wordpress.


Step: 2
   - Start your Apache and MySQL services from XAMPP Controler Panel.



Step: 3
   - After start success MySQL service open phpMyAdmin in browser and create new database.



Step: 4
   - Now unzip downloaded wordpress zip file here: c://xampp/htdocs/your_folder/

Step: 5
   - After unzip file you have one wp-config-sample.php file, rename this file name to wp-config.php.

   - Open wp-config.php file in any editor for change databse details. And change following details on this file (by default username: 'root', password: '', hostname: 'localhost')

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_demo');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', '');

/** MySQL hostname */
define('DB_HOST', 'localhost');


Step: 6
   - Need some other wordpress configuration, So open this path in browser http://localhost/your_folder and you have option for select language and press continue button

Step: 7
   - Now you need to insert wordpress admin details like Site tile, username, password and email address, So fill this details and install wordpress


Step: 8
  - After wordpress installed you get successfully message and wordpress admin login link to access wp-admin.

Spte: 9
  - On wordpress admin page you should enter username and password to access wordpress admin.




Enjoy! And my next tutorial is How to post a blog from wordpress admin?


January 17, 2017

Wordpress admin - How add custom column in post listing table?


- If you want to add custom column in wordpress admin all post listting, then you just need to add some function on functions.php file.

- Here I try to explain with one example like if you want to add Post ID on admin post listing page.



- Example:

File: wp-content/yourtheme/functions.php

//BELOW FUNCTION FOR DISPLAY HEADER TITLE
add_filter('manage_posts_columns', 'columns_header');

function columns_header('$default') {
 $default['post_id'] = 'Post ID';
 return $default;
}


//BELOW FUNCTION FOR DISPLAY VALUE ON THAT COLUMN

add_action('manage_posts_custom_column', 'columns_content', 10, 2);

function columns_content($column_name, $post_id) {
 if($column_name == 'post_id') {
  echo $post_id;
 }
}

Enjoy!

December 16, 2016

Wordpress temporary session to save any message?



If you need to save any error OR success message on wordpress function.php file OR any other file then please follow below steps:

Here I explain with one success message save on function file and display on home page:

function.php

<?php
function myTempFun() {
   if(!session_id()) {
       session_start();
   }
   $_SESSION['my_session_name'] = 'Write here any message';
}
?>

home page template.php

if ( array_key_exists( 'my_session_name', $_SESSION ) ) {?>
    <p><?php echo $_SESSION['my_session_name']; ?></p>
<?php
    unset( $_SESSION['my_session_name'] );
}

After session display also unset that , So when you refresh page then second time that session not displaying.

Enjoy!

August 4, 2015

How to reorder billing fields in WooCommerce Checkout template?


Yes its possible using the some change in functions.php file,

Please do the following some change in woocommerce_form_field() function,


There is one below function:

<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>

Please replace with this:

<?php
$mybillingfields=array(
    "billing_first_name",
    "billing_last_name",
    "billing_company",
    "billing_address_1",
    "billing_address_2",
    "billing_city",
    "billing_state",
    "billing_postcode",
    "billing_country",
    "billing_email",
    "billing_phone",
);
foreach ($mybillingfields as $key) : ?>
<?php woocommerce_form_field( $key, $checkout->checkout_fields['billing'][$key], $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>

You can change position of each fields what ever you want.

Enjoy!

May 26, 2015

Woocommerce how to add to cart button direct redirect to checkout page?

Yes its possible using a simple wordpress function.

Please add following function in your theme functions.php file.

add_filter ('add_to_cart_redirect', 'redirect_checkout');

function redirect_checkout() {
    global $woocommerce;
    $checkout_url = $woocommerce->cart->get_checkout_url();
    return $checkout_url;
}

In the latest version of wordperss you also used following shot function.

function redirect_to_checkout() {
    return WC()->cart->get_checkout_url();

}

Enjoy!

The Future of Technology: Emerging Trends to Watch in 2025

Introduction As we navigate through 2025, the technological landscape continues to evolve at an unprecedented pace. Innovations that once se...