How to list all the posts in a personalized page? WordPress

There is a pretty simple way to query outside the loop using get_posts. Setting post_status => ‘any’ could net you all. The code below queries posts, pages and attachments. The loops through and outputs them all to an unordered list. $pages = get_posts( array( ‘post_type’ => ‘page’, ‘post_status’ => ‘any’, ‘numberposts’ => -1, )); $posts … Read more

Show only first image of multiple image field

Below are four examples of getting a list of items, returning the first and showing a single image from the first id. explode assumes your data is in a string separated by commas. get_attached_media pulls all the attached items in a post then renders the first from that list get_post_meta assumes the data lives in … Read more

Send Order Confirmation automatically to customer’s mobile number

This is an e-commerce plugin called Woocommerce, you need to read up on their hooks, such as woocommerce_new_order here. The code you pasted would usually go inside the active theme’s functions.php. All the themes are located in wp-content/themes, you can easily check which theme is active in the admin dashboard under Appearance -> Themes in … Read more

Update another users meta

wp_ajax_nopriv_{$action} can trigger a non-logged in ajax request. add_action( ‘wp_ajax_nopriv_add_foobar’, ‘prefix_ajax_add_foobar’ ); function prefix_ajax_add_foobar() { // Handle request then generate response using WP_Ajax_Response } get_user_by can pull the user’s data via email $user = get_user_by(’email’, ‘[email protected]’) update_user_meta can update the user’s metadata. update_user_meta( $user->ID, $meta_key, $meta_value, $prev_value );

Jquery autosave text area after typing

Am not sure what is your ID. Let as assume the ID as example Here is the code jQuery(function($) { $(‘#example’).on(‘keyup’, function() { if(autosave_timer) { clearTimeout(autosave_timer); } autosave_timer = setTimeout(save_by_ajax, 3000); // after 3 second of keyup save_by_ajax function will execute }); function save_by_ajax(){ var mid=$(this).attr(‘data’); var tid=’#’+mid; $(tid).jqte({“status” : false}); var content = $(tid).html(); … Read more

add additional anchors in navigation menu

Defining a Menu You must define a menu before you can add items to it. Login to the WordPress Dashboard. From the ‘Appearance’ menu on the left-hand side of the Dashboard, select the ‘Menus’ option to bring up the Menu Editor. Select Create a new menu at the top of the page Enter a name … Read more