External WordPress API

As of WordPress 4.7 (released December 2016), a REST API is provided out of the box on WordPress. As you’re probably aware, REST APIs are interfaced with by standard HTTP GET and POST requests, so if you have a WordPress 4.7 installation, you can access it at this URL, by plugging this into your browser: … Read more

Retrieving pages with multiple tags using REST API

I ran into the same problem but for posts. I found how to OR or AND tags together here: https://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters To get entries that have both L1 AND L2 AND L3 ; use plus (+) https://example.com/cms/wp-json/pages?filter[tag]=L1+L2+L3 In case somebody else comes along and wants to OR terms together I’ll save you the trouble: To get … Read more

WordPress JSON output

If you are using PHP 5.2+ you’re best bet is to just make a PHP array or object and use json_encode(). UPDATED: $cats = get_categories(); $output = array(‘categories’ => array()); foreach ($cats as $cat) { $cat_output = array( ‘cat_id’ => $cat->term_id, ‘cat_name’ => $cat->name, ‘posts’ => array(), ); // should be able to use -1 … Read more

What is the best way to get directory path for wp-config.php?

I came up with this solution. This function checks in each directory level starting from the directory of the current file for the file wp-config.php. <?php function find_wp_config_path() { $dir = dirname(__FILE__); do { if( file_exists($dir.”/wp-config.php”) ) { return $dir; } } while( $dir = realpath(“$dir/..”) ); return null; } ?> To actually include the … Read more

Set up WP Authentication from External API

Update: Made a blog post to explain this better 🙂 I was able to do this by WP’s authenticate filter inside a new plugin; most of which is guided by this tutorial by Ben Lobaugh. Major points on the plugin: Make an API call function using cURL (you can get guide codes from Postman upon … Read more

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