WordPress Codesnippets

Change language programmatically


This code checks if the WordPress multilingual plugin “WPML” is installed on the website. If it is, it sets the current language to English. icl_object_id is a function of WPML used to retrieve the translated version of an object or post. icl_get_current_language retrieves the current language of the page and icl_set_current_language sets the current language of the page to the specified language.

Was this code snippet helpful?

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmatically save post

This code creates a WordPress post with the values of the ‘post_title’ and ‘post_content’ variables. It sets the post status to ‘publish’ and the author

Read More »

Create order programmatically

This code creates a new post in the WordPress database with post type ‘shop_order’, post title ‘Order #12345’, post status ‘wc-processing’, and ping status ‘closed’.

Read More »