How to localize a script in WordPress

Before we localize a script, we need to register a script first. Because without this, we can not localize any script. Because to localize a script, we need a registered script handle. Here is the syntax to register a script. wp_enqueue_script( $handle:string, $src:string, $deps:array, $ver:string|boolean|null, $in_footer:boolean ) wp_enqueue_script( ‘myjs’, ‘path_to_js_file’, array( ‘jquery’ ), ‘1.0’, true… Continue reading How to localize a script in WordPress

Published
Categorized as Dev

How to change custom post type slug without loosing data

Sometime it happens, that at first we create custom post type, register taxonomy and insert some data for that custom post type. After moving forward, then we realise that, we need to change the slug for that custom post type. There might be some reason for this. Whatever the reason is, when we change the… Continue reading How to change custom post type slug without loosing data

WordPress Query Basics

Show all posts from a custom post type WordPress has a small function get_posts() to do this job. You just need to set your arguments and pass that argument inside the function. It returns an array of latest posts. You can use foreach function to loop though the returned array. Show all posts for a… Continue reading WordPress Query Basics

Query to show related post

We developer survive each and everyday and always spent a lot of time in google to find a simple solution for our day to day problem. Show related post in a single post is one of them. Today I also spent more than one hour in google to find this solution for a custom post… Continue reading Query to show related post

Published
Categorized as Dev, Query

WP CLI : Error establishing a database connection in LocalWP

If you are using localwp for your local WordPress development then you might be face this database error issue at first time in WP CLI connection. Same things happen to me. Thats why I am helping you out. Here is the simple solution. You need to replace your DB_HOST from your wp-config.php file like below.… Continue reading WP CLI : Error establishing a database connection in LocalWP

Solve mysql is not recognized as an internal or external command

In command terminal of windows 10, mysql command is not rea By default windows 10 command terminal does not recognize mysql command. You need to add your server mysql path in you environment variable. Go to you server mysql path like mine. Add the above path in you environment variable. If you don’t know how… Continue reading Solve mysql is not recognized as an internal or external command