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

Twitter feed – Failed to open stream [closed]

How to do remote requests in WordPress: Use the appropriate API First, there’s the WP HTTP API, which should be used for such tasks. And second, one should never ever use the @ operator, as this one suppresses error messages or notices and will successfully lock you out from troubleshooting your bugs. Just because you … Read more

Save JSON object attributes to custom metabox

I’ve found a possible solution. Not sure if it is safe though jQuery(function(jQuery) { // Uploading files var file_frame; var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id var set_to_post_id = 5; // Set this formfield = jQuery(this).siblings(‘.custom_upload_image’); preview = jQuery(this).siblings(‘.custom_preview_image’); // Create the media frame. file_frame = wp.media.frames.file_frame = wp.media({ multiple: false // Set … Read more

Parse wordpress blog data using json api and ajax

Got this working: Added html += ”; html += ‘<li>’; html += ‘<a href=”‘ + entry.link + ‘”>’; html += ‘<div class=”entry”>’ + entry.title + ‘</div>’ ; html += ‘<div class=”entry”>’ + entry.author + ‘</div>’ ; html += ‘<div class=”entry”>’ + entry.publishedDate + ‘</div>’; html += ‘<div class=”entry”>’ + entry.contentSnippet + ‘</div>’; html += ‘</a>’; … 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