XML to Json code issue

Use this function form http://www.php.net/manual/en/function.json-encode.php#80339 function json_format($json) { $tab = ” “; $new_json = “”; $indent_level = 0; $in_string = false; $json_obj = json_decode($json); if($json_obj === false) return false; $json = json_encode($json_obj); $len = strlen($json); for($c = 0; $c < $len; $c++) { $char = $json[$c]; switch($char) { case ‘{‘: case ‘[‘: if(!$in_string) { $new_json … Read more

Retrieving a JSON feed of my posts and displaying thumbnails

Try something like this: $posts = $query->get_posts(); foreach($posts as $p){ $thumb_id = get_post_thumbnail_id($p->ID); $src = wp_get_attachment_image_src($thumb_id, ‘image_size’); $url = $src ? $src[0] : false; $p->image_url = $url; } $json = json_encode($posts); Now you can echo out $json into your JS var. You will find the image url string in the key image_url of your json … Read more

How to display partial values of JSON Encode values

Use json_decode: global $wpdb; $project_member_details = $wpdb->get_var( $wpdb->prepare( “SELECT project_members FROM wpxa_orocox_project_members WHERE project_id = 603” ) ); $project_member_details = json_decode( $project_member_details, true ); print_r( $project_member_details[‘member_image’] ); If you still want the output to be JSON encoded at the end of it, you could then do something like: $member_images = $project_member_details[‘member_image’]; echo wp_json_encode( [ ‘member_image’ … Read more

Strange “lea” prefix on wp-json

I found it. There’s a bug in the TotalPress.org Custom Post Types plugin in the file: wp-content/plugins/custom-post-types/custom-post-types.php At the top of the file, you will see the mistake: lea<?php When I remove the lea, the problem goes away. I’m contacting the plugin developer to let them know. Plugin version was 3.0.12.

JSON-LD: creating an AggregateOffer from many shortcode

If you have full control over the system, it would be best to get all of the data by some other means. If you must concatenate the shortcodes, you can parse the content to get the shortcodes with get_shortcode_regex(). You can save all the matches, and their attributes, and remove them from the content. Then, … 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

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?

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