Add Products to Woocommerce through WP API

After a lot of searching and banging my head everywhere I have successfully implemented to add WooCommerce products through Rest API. Here is my complete working code for reference :- $api_response = wp_remote_get(‘www.myapi.com’); $body = wp_remote_retrieve_body($api_response); /****** API not ready yet…working on it *******/ $data = [ ‘type’ => ‘variable’, ‘description’ => ‘Trying it out … Read more

add_theme_support using a plugin

Figured it out after playing with Rarsts answer here. Here is what I ended up with: <?php /* Plugin Name: Bootstrap Genesis Addons Plugin URI: https://github.com/bryanwillis/bootstrap-genesis-addons Description: A collection of mini plugins/addons to apply specific changes to my site. Version: 1.0 Author: Bryan Willis Author URI: https://github.com/bryanwillis/ License: MIT License License URI: http://opensource.org/licenses/MIT */ function … Read more

How to get shortcode to work inside a foreach loop called within a shortcode?

The issue is you are echoing raw post_content field from object. It isn’t what usually gets to front-end. Try: apply_filters( ‘the_content’, $post->post_content ) If you want to run shortcodes alone (without bunch of other filters) you can do: do_shortcode( $post->post_content ) Edit re-read your question… Is there a possibility that this thing gets recursive? Post … Read more

How to add more than 1 user role to sub-menu pages

The easiest way is create 2 custom capabilities and assign both to administrators, one to role coach and one to role player. When you create your roles you do something like this: $coach_caps = array( ‘read’ => true, ‘something_else’ => true, ‘can_open_coach_menu’ => TRUE // this is important for your scope ); add_role( ‘coach’, ‘Coach’, … Read more

Is it possible to create an action hook using do_action() within add_action()?

Creating an answer based upon responses via comments on original question of: Is it possible to create an action hook using do_action() within add_action()? Yes it is possible to create an action hook using do_action() on a call to add_action(). For clarification, the following code does NOT work: add_action(‘init’, do_action(‘my-hook-name’)); As stated by @IvanHanák in … Read more

External Rewrite Rules

Here’s a quick (hopefully error-free!) example of adding an internal rewrite and loading a plugin file to process those requests. This will give you access to the WordPress environment so you can use the database, etc.. The general steps are: add your rewrite and point it to index.php with your custom query vars appended register … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)