Sql formatting for post data within function

It isn’t showing wp_posts.post_content LIKE ‘%test%’ because the wildcards (%) in the prepared statement are converted to placeholder escape strings (like the {a19f0a6c3d866f7270be0f3954cbb2600270400c15f488e112449a8a131701f0} in your post) when wpdb::prepare() calls wpdb::add_placeholder_escape() which “Adds a placeholder escape string, to escape anything that resembles a printf() placeholder“, i.e. a placeholder like %s. But those placeholder escape strings will … Read more

Include results with tags relevant to the search keyword with JSON rest API v2

WP Extended Search does not work with REST by default since version 2.0.2 This is to achieve maximum compatibility with WordPress and other plugin/themes. To enable the support, pass wpessid in REST request with ID (for specific search setting) or without ID (for global search setting). e.g. /wp-json/wp/v2/posts?search=technology&wpessid or /wp-json/wp/v2/posts?search=technology&wpessid=10 Ref: https://wordpress.org/support/topic/search-queries-with-metakey-name-issue-version-2-0-2/#post-14376988 PS:- I am … Read more

Upload data from weather station to WordPress Website

This is a pretty good application of WordPress’s REST API, which would enable you to update the data via a POST request containing the new data in JSON format and poll for changes with GET requests to the same endpoint. While you could establish this functionality with traditional AJAX request handlers, I think it makes … Read more

Adding inside wp-plugin jQuery script that receives JSON-formatted data, generated by php-function inside this plugin

Have a read of AJAX in Plugins, then see if you can adapt this code to what Highcharts is wanting: add_action(‘wp_ajax_wpse_77392_get_json’, ‘wpse_77392_get_json’); add_action(‘wp_ajax_nopriv_wpse_77392_get_json’, ‘wpse_77392_get_json’); function wpse_77392_get_json() { global $wpdb; $sql = ” SELECT `date`,`value` FROM {$wpdb->prefix}table_name WHERE `date` BETWEEN ‘2011’ AND ‘2012’ ORDER BY `date` ASC; “; $results = $wpdb->get_results($sql); $json = json_encode($results); header(‘Content-type: application/json’); … Read more

JSON API not showing full content

You can try this to show the full post content only in the JSON API: function remove_more_wpse_96740($content) { if(get_query_var(‘json’)){ global $post; $content = preg_replace(‘/<!–more(.*?)?–>/’,”,$post->post_content); } return $content; } add_filter(‘the_content’, ‘remove_more_wpse_96740’,1); by targeting the json query variable and remove the <!–more–> part of the post. If you have a custom string like <!–more But wait, there’s … Read more

Create WordPress posts from JSON array using plugin in admin

Here I assume your json is an array of object where properties are named like wp_insert_post arguments: ‘post_title’, ‘post_content’ and so on. function process_ajax() { if ( ! isset($_POST[‘nonce’]) || ! wp_verify_nonce($_POST[‘nonce’], ‘mynonce’) ) die(‘error on checking nonce’); if ( ! isset($_POST[‘filepath’]) die(‘no file given’); if ( ! file_exists($_POST[‘filepath’]) ) die(‘invalid file given’); $posts = … Read more

WP REST API. Configuring JSON routes

In the latest version of the API (2.0 ) the wp part is the namespace of core, default routes. This means that the core routes have URLs like “wp-json/wp/posts“, while a custom route would be something like “/wp-json/woo-comm/sizes“. The documentation just hasn’t caught up yet. Which version are you using?

Retrieve JSON file from JS trough php

I’m not convinced this is the cleanest way to do it but at least it work until I find something more efficient: function json_gmap(){ $get_file = file_get_contents(get_template_directory_uri() . ‘/data/my.json’); $json_to_array = json_decode($get_file,true); die (json_encode($json_to_array)); } add_action(‘wp_ajax_json_gmap’, ‘json_gmap’); add_action(‘wp_ajax_nopriv_json_gmap’, ‘json_gmap’); Basically I decode my Json file to an array and the re-encode it to have it … Read more

How can I modify the element on all pages?

The <header> elements are usually echoed directly by the theme. So without any hook or filter to change them. In that case, there is no way to change those elements with a function. Check your theme. You could, of course, use javascript to place you attributes, but that would happen on the user end. Search … Read more