How to send a HTTP Post request using PHP Curl and WordPress

I managed to solve this by adding the following into my functions.php add_shortcode(‘my_shortode’, ‘my_function’); function my_function () { $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_PORT => “2222”, CURLOPT_URL => “http://11.111.11.111:2222/folder/query”, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => “”, CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => “POST”, CURLOPT_POSTFIELDS => “<root>\r\n <something1>username</something1>\r\n <something2>123456789</something2>\r\n <something3>Hello</something3>\r\n</root>\r\n”, CURLOPT_HTTPHEADER => … Read more

Get post categories

You’ll need to echo back your results in PHP. foreach($category_detail as $cd){ echo $cd->cat_name; } Also you might want to consider putting something between each category. If you have categories/terms like Blue, Red, Green. Then how you are currently looping over them, it will print it back as: data-category=”BlueRedGreen” Hope that helps!!

Can not add admin notices from the edit_user_profile_update hook (notices not being displayed)?

WordPress redirects you back to the user-edit.php page upon successful user update, so while the admin_notices has yet been fired in your sulock_save_profile_fields(), the message (your custom admin notice) is never displayed because of the redirection. And one way to fix it, is by filtering the redirect URL via the wp_redirect filter: // In sulock_save_profile_fields() … Read more

Adding regular php file to site

You could accomplish this by setting up a redirect. If you’re using an Apache server, for your example, you would add this to .htaccess above the WordPress block: RewriteEngine On RewriteRule somepost.php ^/somepost/ It’s much more common, and recommended, to create a PHP file and a Page (or other post type) within wp-admin). This will … Read more

How do I get my Javascript scripts working?

You must have to include wp_head() in header.php and wp_footer(); in your footer.php header.php <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <title>Title</title> </head> <?php wp_head(); ?> <body> footer.php <?php wp_footer();?> </body> </html> if you do not add wp_head() AND wp_footer() WordPress hook does not fire using wp_enqueue_scripts hook .

Get related product based on subcategory selected from category id with ID 142

you can use this code or adapted to work for you case,, hope its work.. Add it to your function.php add_filter( ‘woocommerce_product_related_posts’, ‘woocommerce_get_direct_related_products’ ); function woocommerce_get_direct_related_products() { global $woocommerce, $product; // Related products are found from category $cats_array = array(0); // Get categories $terms = wp_get_post_terms( $product->id, ‘product_cat’ ); //Select only the category which doesn’t … Read more

My website is not showing Footer section

Please add below code in your footer.php file above included JavaScript files : <?php if ( is_active_sidebar( ‘footer-1’ ) ){ dynamic_sidebar( ‘footer-1’ ); } if ( is_active_sidebar( ‘footer-2’ ) ){ dynamic_sidebar( ‘footer-2’ ); } if ( is_active_sidebar( ‘footer-3’ ) ){ dynamic_sidebar( ‘footer-3’ ); } ?>