WP Multisite – Additional subdomain on the site for API purposes

I have resovled it myself. I have enabled sunrise in wp-config. Then add a script to sunrise.php to override HTTP_HOST. I made it dynamic since we have many websites. When you visit api.domainxy.com it automatically shows you domainxy.com. <?php $re=”/(?:api\.)(.*)/m”; $str = $_SERVER[‘HTTP_HOST’]; preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0); if ($matches && $matches[0][1] != “”) { … Read more

Creating tags via API

Hi @James: If you have the post ID of your newly created post (the $created variable from your question) you use the wp_set_object_terms() function, for example: wp_add_post_tags($created,’My First Tag’); wp_add_post_tags($created,’My Second Tag’); wp_add_post_tags($created,’My Third Tag’);

Plugin is a widget, but I want to call it in the head, can I?

The correct “WordPress” way of doing it would be to use the_widget template tag to display widgets anywhere you want. so in you case you would something like this: $instance[‘account’] = ‘account name’; //Ustream channel name $instance[‘online’] = ‘http://www.online_image.URL’; $instance[‘offline’] = ‘http://www.offline_image.URL’; the_widget(‘wp_ustream_status’, $instance);

How can I call specific function if requested URL is not found?

Simply use template_redirect filter to perform check on request you get in wordpress. add_filter(‘template_redirect’, ‘my_404_override’ ); function my_404_override() { global $wp_query; if (!$wp_query->post) { // Check if any post is found. If not its 404. status_header( 200 ); $wp_query->is_404=false; // Create post object $my_post = array( ‘post_title’ => ‘My post’, ‘post_content’ => ‘This is my … Read more

Integrate product feed API in Woocommerce [closed]

There is a similar problem to create posts from an API and programmatically generating posts. Essentially just parse the JSON into an array, grab the fields you need, and create the post/product. You most likely need to pull the images as well. You should also consider if the post already exists in your database and … Read more