Appery.io and WordPress

If you’re using WordPress 4.6, you can use the REST API without the need for the plugin by simply using the following: add_action(‘rest_api_init’, function() { $namespace=”myapi”; register_rest_route($namespace, ‘/myroute’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘handle_my_route’ ), true); function handle_my_route() { return ‘Hello World!’; } } Then, going to: yourwebsite/wp-json/myapi/myroute would return the callback value, which … Read more

Dynamic iCal generator outside/inside wordpress

I would use WordPress’ feeds. You can create your own feed with add_feed. You specify a callback and this callback is responsible for displaying the output. Creating a feed add_feed(‘my-events’,’wpse56187_ical_cb’); wpse56187_ical_cb is that responsible for getting the events (use WP_Query), looping through them and printing the ICAL fields. Downloading the ICAL file If your feed … Read more

How to load wordpress environment without loading the template?

If you place the file in the WP root directory, e.g. http://mysite.com/myscript.php require( dirname(__FILE__) . ‘../blog/wp-load.php’ ); if (function_exists(‘wp_create_user’)) { echo “wp_create_user() found”; } If you are in a different directory, just make sure you are loading wp-load.php from the proper location.

How to call a function in wordpress plugin from another site

There are two way you can implement this 1. Use the AJAX API This is the fastest way of doing it. Just register an ajax action and use that action url to send requests. Example add_action(‘wp_ajax_api-call’, ‘wpse_156943_ajax_api_handle_request’); function wpse_156943_ajax_api_handle_request(){ // security check validation // do whatever you want to do } The url for the … Read more

Showing content from another wordpress installation database in the page template loop?

On your edit2: If it’s exactly the same, could you add echo apply_filters(‘the_content’, {$mypost->post_content}); to apply the_content filter to parse the shortcodes? Also, why not use the multi-site feature of WordPress? If so much is identical, it seems more straightforward to update if your code is not duplicated. And for shared content you could then … Read more

Displaying content from one WP site on separate WP site

Yeah $wpdb2 = new wpdb(‘dbuser’, ‘dbpassword’, ‘dbname’, ‘dbhost’); // get 10 posts, assuming the other WordPress db table prefix is “wp_” $query = “SELECT post_title, guid FROM wp_posts WHERE post_status=”publish” AND post_type=”post” ORDER BY post_date DESC LIMIT 10″; $someposts = $wpdb2->get_results($query, OBJECT); foreach($someposts as $somepost) echo “<a href=\”{$somepost->guid}\”>{$somepost->post_title}</a><br />”; Another way is to use the … Read more