Month: April 2018

Common Git Commands

Common Git Commands

Go to the directory you want to initiate Git and then follow the commands:

  1. Initiate the git:
    git init
  2. Remove Git if you have initiated in a wrong place ( Be aware if there is another git in the subdirectory):
    rm -rf .git
  3. To add all the files(including subdirectory) to the staging step:
    git add .
    Or,
    git add -A
  4. Git branch –
    a. Create a new one from the current branch and Checkout to the new branch:
    git checkout -b newBranch
    b. Delete a branch branch:
    git branch -d branchName
    
  5. Merge master to development branch –
    1. //pull the latest changes of current development branch if any 
    git pull (current development branch)

    2. //switch to master branch
    git checkout master

    3. //pull all the changes if any
    git pull

    4. //Now merge development into master
    git merge develop

    5. //push the master branch
    git push origin master

After Installation of Visual Studio Code

Go to Preferences  → Settings and then paste code within {} brackets –

"editor.minimap.enabled": true,
"files.autoSave": "afterDelay",
"editor.autoIndent": true,
"editor.detectIndentation": true,
"editor.fontSize": 14,
"editor.wordWrap": "on",

 

Thanks!

 

 

Change Custom Post Type Name Safely.

Just replace the second line’s post type names:

global $wpdb;
$old_post_types = array('old_type' => 'new_type');
foreach ($old_post_types as $old_type=>$type) {
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET post_type = REPLACE(post_type, %s, %s) 
                         WHERE post_type LIKE %s", $old_type, $type, $old_type ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET guid = REPLACE(guid, %s, %s) 
                         WHERE guid LIKE %s", "post_type={$old_type}", "post_type={$type}", "%post_type={$type}%" ) );
    $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->posts} SET guid = REPLACE(guid, %s, %s) 
                         WHERE guid LIKE %s", "/{$old_type}/", "/{$type}/", "%/{$old_type}/%" ) );
}

 

Source: https://wordpress.stackexchange.com/questions/97026/how-do-i-safely-change-the-name-of-a-custom-post-type