WordPress ajax error 400 bad request for sending data to remote site [duplicate]

Your action name and hooks don’t match. You have hooked to _ajax_news in the hook name: add_action( ‘wp_ajax_nopriv_ajax_news’, ‘ajax_news’ ); add_action( ‘wp_ajax_ajax_news’, ‘ajax_news’ ); But the action you are sending in JavaScript is ajaxnews, without the underscore: ‘action’: ‘ajaxnews’, //calls wp_ajax_nopriv_ajaxnews See how your own comment has a different name than the actual hooks you’ve … Read more

How can javascript be added to a custom-page.php template?

Save your JS in a seperate file and use a Conditional to Enqueue it. Something like this will work. function my_enqueue_stuff() { if (is_page_template(‘custom-page.php’)) { wp_enqueue_script( ‘my-functions’, get_stylesheet_directory_uri() . ‘/my-functions.js’, array(‘jquery’), filemtime(get_stylesheet_directory() . ‘/my-functions.js’) ); } } add_action( ‘wp_enqueue_scripts’, ‘my_enqueue_stuff’ ); The above will go in your Child Theme’s functions.php file.

Post title and url not showing on google map marker [closed]

I have solved it by doing it like this. function myMap() { var gmarkers = []; var markers = []; var infowindow = new google.maps.InfoWindow({ content: ” }); var myCenter = new google.maps.LatLng(44.794426, 20.451849); var mapProp = {center:myCenter, zoom:15, scrollwheel:false, draggable:true, mapTypeId:google.maps.MapTypeId.ROADMAP}; var map = new google.maps.Map(document.getElementById(“googleMap”),mapProp); var myJsarray = passed_object.retrieve_data; var latitute=”” ; var … Read more

Filtering markers on google map by WordPress category[SOLVED]

Solved, the problem was in filterMarkers() function filterMarkers = function (category) { var markers = gmarkers[i]; for (var i = 0; i < gmarkers.length; i++) { // If is same category or category not picked if (gmarkers[i].category == category || category.length === 0) { gmarkers[i].setVisible(true); } // Categories don’t match else { gmarkers[i].setVisible(false); } } … Read more