API page return Header 500 but Work
I have solver with die; After echo. if(strpos($_SERVER[‘REQUEST_URI’], “index.php?wpse9870_api=1”)) { header(“HTTP/1.1 200 OK”); echo “v1p”; die; } Header is now 200;
I have solver with die; After echo. if(strpos($_SERVER[‘REQUEST_URI’], “index.php?wpse9870_api=1”)) { header(“HTTP/1.1 200 OK”); echo “v1p”; die; } Header is now 200;
Try this code function get_users(){ $all_users = get_users(); $arr=array(); foreach ($all_users as $val) { $arr[]=array( ‘value’=> $val->data->user_nicename, ‘label’=> $val->data->display_name, ‘icon’ => get_avatar_url($val->ID)); } wp_send_json($arr); }
WordPress API only returning HTML
Complex PHP for json_encode > how to handle/output right?
You don’t need to specify datatype in your AJAX call. Also, WP handles AJAX a bit differently, primarily: $(‘#filter_evenement’).submit(function(){ jQuery.ajax({ url:ajaxurl, type:”POST”, data : {action: “evenements_filter_function”, val1: “value1”, val2: “values2”}, success:function(data){console.log(data); var dataArray = jQuery.parseJSON(data);//parse JSON }, fail: function( jqXHR, textStatus, errorThrown ) { } }); }); data has to contain action which specifies the … Read more
Access featured image URL based on media ID?
WordPress PHP error getting posts from another wordpress blog
Yes that would be easy. You can use the get_the_permalink() function to retrieve a post’s link. Here’s how to do it: // You are storing the post data here $posts_arr[] = $post; // Add the URL to the same array element $posts_arr[][‘url’] = get_the_permalink(); You can get the index of the current post in the … Read more
I have found the solution with the help of a great friend. I will post it here if anyone else needs to utilize the fucntion. Again in summary, this function will display posts from another blog and you can enter specific category ID’s from the other blog and also control how many posts are displayed. … Read more
403 error for ajax POST request