Category Archives: WordPress

What is My WordPress Site’s Login URL

I just installed WordPress script on my hosting, but I dont know the admin login URL of WordPress

Typically, you can access login page via the following URLs

  • http://www.example.com/login/
  • http://www.example.com/admin/

However if permalink  or seo friendly URL is not working, you can access login page via the following URL

  • http://www.example.com/wp-login.php
If  your WordPress was installed in a sub-folder such as /wp/

You can access login URL  via the following URLs

  • http://www.example.com/wp/login/
  • http://www.example.com/wp/wp-login.php
If your WordPress was installed on a sub-domain

You can access login URL via the following URLs

  • http://sub-domain.example.com/login/
  • http://sub-domain.example.com/wp-login.php

How To Execute Woocommerce Payment Programmatically

How to trigger Woocommerce payment process like checkout but it should process in the background

To trigger Woocommerce payment process, need to call “process_payment” method. Here is an example to process Woocommerce payment programmatically.

global $woocommerce;
$address = array(
      'first_name' => 'Test',
      'last_name'  => 'Test',
      'company'    => 'Test',
      'email'      => 'test@softwarehtec.com',
      'phone'      => '00-00-0000',
      'address_1'  => '0 test st',
      'address_2'  => '',
      'city'       => 'Test',
      'state'      => 'NY',
      'postcode'   => '10010',
      'country'    => 'US'
);


$order = wc_create_order();
$order->add_product( get_product('1'), 1); 
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$order->calculate_totals();

update_post_meta( $order->id, '_payment_method', 'paypal' );
update_post_meta( $order->id, '_payment_method_title', 'PayPal' );

WC()->session->order_awaiting_payment = $order->id;

$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
$result = $available_gateways[ 'paypal' ]->process_payment( $order->id );

if ( $result['result'] == 'success' ) {
    $result = apply_filters( 'woocommerce_payment_successful_result', $result, $order->id );
    wp_redirect( $result['redirect'] );
    exit;
}


How To Set Parenet Page For A WordPress Page Programmatically

I would like to set parent page for some WordPress pages, I knew how to update from backend. However I would like to know how can I set parent page programmatically

Set Parent Page For New Page

We can set value of post_parent which is assigning a parent page to the page when that was created.
$tmp_post = array(
    'post_type' => 'post',
    'post_title' => 'Child Page',
    'post_parent' => 'parent page ID',
    'post_content' => 'Child Page Content'
);
$tmp_post_id = wp_insert_post ( $tmp_post, true );

Set Parent Page For Existed Page​

For existed page, we can use wp_update_post to assign a parent page for a page.

wp_update_post(
    array(
        'ID' => $child_id, 
        'post_parent' => $new_post_id
    )
);

How To Disable Gutenberg Editor For WordPress 5.0

Once my site upgraded to the latest version, I can’t edit/add the page or post anymore, look like the new editor – Gutenberg has trouble with my other plugins. How can I disabled Gutenberg editor for WordPress 5.0

If you would like to disable new editor – Gutenberg for WordPress 5.0, there are 3 options

Option 1 - Install The Classic Editor WordPress Plugin

You can install the Classic Editor WordPres – Plugin Home. Once install the plugin, you can switch the editor between Gutenberg and TinyMCE

Option 2 - Install WordPress Plugin "Disable Gutenberg"

There is another WordPress plugin you can use to disable WordPress 5.0 new editor. Disable Gutenberg which is the similar plugin as “Class Editor” which is allowing you to remove Gutenberg editor complete and even “Gutenberg admin notice”

Option 3 - Disable Gutenberg editor via Code

You can place following codes within your function.php page. For the version newer than WordPress 5.0 beta
add_filter('use_block_editor_for_post_type', '__return_false', 100);
For other verions
add_filter('gutenberg_can_edit_post_type', '__return_false');
To disable Gutenberg for Meta Boxes

When adding the meta box, we can pass argument to disable Gutenberg editor.

add_meta_box('metabox_id', 'Metabox Name', 'metabox_callback', null, 'advanced', 'default', array('__block_editor_compatible_meta_box' => false));