Tag Info

New answers tagged

1

Here is what I ended up doing based on @gdaniel's suggestion: AJAX call: $('.btn').click(function() { $.ajax({ url:"<?php bloginfo('template_directory'); ?>/inc/galleries.php", type: 'POST', data: {postID: '<?=$post->ID;?>', galleryCategory: $(this).attr("data-content")}, success: function(resp) { ...


0

because the Heartbeat system is mostly orthogonal to the rest of wordpress and therefor it is not really aware what is the content of the pages it runs on. As it is a relatively new system it probably has edges that are not well defined or tested, and if you think there is some weird behaviour or an actual bug please open a ticket at the wordpress trac - ...


0

Your are pointing to a non existing AJAX file. $.ajax( { // ... url : '/path/myfile.php', // ... } ); WordPress has a predefined file for that: admin_url( 'admin-ajax.php' ) When you are running public queries, then you need to add it to wp_localize_script( 'your-script-handle', 'yourJavaScriptAccessibleObject', array( 'ajaxurl' ...


3

First, like many things in WordPress, it's not like someone decided "let's make this neat and convenient". It was more like someone slapped it together for something, then it got used more in admin, then it got used a lot in admin, then it became kind of practice to use it for non-admin as well. Or something along these lines. Second, it's not as much what ...


1

I have made some changes to your code. See now if this works - function myajax_inputtitleSubmit_func() { // check nonce $nonce = $_POST['nextNonce']; if ( ! wp_verify_nonce( $nonce, 'myajax-next-nonce' ) ) die ( 'Busted!'); $zipcode = $_POST['zip']; // generate the response global $wpdb; $tablename = ...


0

You must first enqueue the script and define the URL. Then you have to create a function for your AJAX callback and add a WordPress action that calls it. Here is a video where I explain it, hope it helps. :) https://www.youtube.com/watch?v=R7OK-TtNuEc


0

You can use get_the_ID(); function to fetch the Id of the current post For more Please visit here


0

I can suggest you another direction : why bother generating a new Control in javascript when you can create controls A and B at the first page load and hide/show them dynamically using javascript ? If I understand well, this was what you described in option 3. Here is a sample code to get you started : class MyCustom_Customize_Control extends ...


0

I have call ajax using bellow code its working good. Here i am sending the variable time to this page using post $.post("'. plugins_url().'/woocommerce-booking/gettime.php", var time=0; jQuery("#time_slot").change(function() { time=time_slot.value; $.post("'. ...


0

I would just put the custom fields in the <li> after the <a> and then show/hide them with your preferred tooltip method, whether it be CSS, JS or a combination of the two: <?php if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <a href="<?php ...


0

Add this in Your Plugin php page add_action("wp_ajax_ajax_plugin_call", "ajax_plugin_call_callback"); add_action("wp_ajax_nopriv_ajax_plugin_call", "ajax_plugin_call_callback"); Ajax Function in Php Page function ajax_plugin_call_callback{ global $wpdb; print_r($_POST) ; // write your Php Code die; } Your Javascript Code like this ...


0

please look at below, it may help to you. Here it is your PHP code. <?php function ajax_enqueuescripts() { wp_enqueue_script('ajaxloadpost', plugins_url().'/your-plugin-name/js/my-ajax.js', array('jquery')); wp_localize_script( 'ajaxloadpost', 'ajax_postajax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' ) ) ); } ...


0

Use the built-in wordpress Ajax actions: Your jquery will look like this: $('#ajax_form').bind('submit', function() { var form = $('#ajax_form'); var data = form.serialize(); data.action = 'MyPlugin_GetVars' $.post('/wp-admin/admin-ajax.php', data, function(response) { alert(response); }); return false; Your plugin ...


0

Whatever caused the issue I noticed that the columns that I had previously had unset were the only one that were showing up after deactivating everything. To fix the issue I unset the missing columns with the following filter: function remove_all_pages_columns_to_fix_hidden($columns) { unset($columns['cb']); // Remove checkbox column ...


0

The URL you are trying to pass to cannot be used (wp-content/themes/stargazer/populate.php) As @Milo pointed out, please check the AJAX Codex, and it will explain the use of 'ajaxurl', which is a protected variable. In short, all AJAX requests must be passed through 'admin-ajax.php' whether it is for the frontend or backend.


0

If you follow the second approach in the linked Q\A, you do not need ajax, but just to pass the array of terms to the script. First of all in your functions.php (or equivalent) enqueue the script and pass the array of trades via wp_localize_script: add_action( 'wp_enqueue_scripts', function() { /* you should check if the page is the one that include the ...


0

You don't need to do this part $tradesList = '["' . implode( '","', $trades ) . '"]'; json_encode converts array to json. EDIT: php code function get_my_suggestions() { // This function should query the database and get results as an array of rows: // GET the recieved data: 'term' (what has been typed by the user) $term = $_GET['term']; $trades = ...


0

You get all terms because you're asking for all terms, in fact, the line $tradeList = get_terms('trade'); just get all the terms, ignoring the 'term' query string passed to file. If you want to get all the terms "filterd" you have to use the string in the query, something like: include_once( '../../../wp-load.php' ); // adjust the path, of course // or ...


0

First off, you should be using WP_Query vs query_posts. Have a look at the Taxonomy Parameters. Mainly tax_query and relation. // Repost from link above $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( 'taxonomy' => 'movie_genre', ...


0

You could check if the response doesn't work right, or if your jQuery-function is messing with it by inserting alert(response); in the first line of your success-function. This way, the responsestring will be shown in an alertbox.


0

I suggest that you use a shortcode to display taxonomy of your choice : create a class to declare the shortcode and call this function public function shortcode($atts) { extract(shortcode_atts( array( 'data' => 'taxonomy', 'taxonomy' => 'category', //get_terms arguments 'parent' => 0, //only get top level terms by default ...


0

Provided that your server receives data in the form of a string which it should if you're using the jQuery serialize() function. It will be something like: name1=value&name2=value&name3=value You just need to parse the string into an array as follows: $parameters = array(); parse_str($_GET, $parameters); See the following for more information: ...


0

I found this and it sped up my ajax. function my_deregister_heartbeat() { global $pagenow; if ( 'post.php' != $pagenow && 'post-new.php' != $pagenow ) { wp_deregister_script('heartbeat'); wp_register_script('heartbeat', false); } } add_action( 'admin_enqueue_scripts', 'my_deregister_heartbeat' );


1

If you're using custom post types, i'd save those date entries as post_meta entries (http://codex.wordpress.org/Function_Reference/add_post_meta). So if your client clicks on a date, you start an ajax request to your plugin/theme file to add or remove a meta entry. you can create one meta_entry named _availability for example and save all dates there (you ...


0

Your ShortCode callback method should take an atts parameter that stores the attributes passed to it from the do_shortcode call which is I am assuming how you are getting the $q parameter for the database query. The callback method should also return instead of echo the output. Without seeing any of the output/error messages I would say you'll need to ...


0

You are not using the Wordpress ajax API correctly, see Ajax in Plugins. Tha action parameter defines a function callback for wp_aja_* action hook, not the name of a file: <?php add_action( 'wp_ajax_my_action', 'my_action_callback' ); //Uncomment next line if you want the ajax action enable in the frontend //add_action( 'wp_ajax_nopriv_my_action', ...


0

You should try to replace the following jQuery part: action: 'process_shortcode_on_tab_click' with this one: action: 'process_shortcode_on_tab_click_action' to match your wp_ajax_process_shortcode_on_tab_click_action and wp_ajax_nopriv_process_shortcode_on_tab_click_action actions. Check for example the Codex on how to name the custom ...


0

AJAX/jQuery is not limited to any specific "area" like plugins or widgets, in fact some plugins consist solely of widgets (although afaik the converse cannot be said). This Smashing article might be a good primer. When you finish with that then check out Gary Cao's WordPress + AJAX tips and come back with a more specific question.


1

You don't need to override Backbone.sync since Backbone.sync will override its own $.ajax request with the parameters you pass as options. See this link for a walkthrough of how Backbone.sync works internally: http://backbonejs.org/docs/backbone.html#section-141 You can add something like the following in your model or collection: save: function(){ var ...


0

Yes you should use die(); in ajax function call, but because you're not returning data and don't care what is returned it's not necessary You should be using nonce, it's good practice to get used to always using it regardless of the situation. http://codex.wordpress.org/WordPress_Nonces http://codex.wordpress.org/AJAX_in_Plugins You should not be using a ...


0

when form (or other) data is submitted via AJAX, it can be accessed via the $_POST or $_GET variables depending on the method used. In your case, you are using the post method so you can access your 'lat' and 'lng' with $_POST['lat'] and $_POST['lng'] and manipulate them as needed.


0

As ungestaltbar said, the variable "data" should contain an object, not a string. function show_trend() { var data = { action: "render_admin_charts_page" } jQuery.ajax({ type: "POST", url: "../wp-admin/admin-ajax.php", data: data, dataType: 'json', ...


1

basically you want to declare this function in another file add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' ); ? if yes then you can place this piece of code in function.php in from your active theme add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' ); function yourfunction() { ?> <div class="wrap"> ...


1

To add action for wordpress ajax If you needed to create an AJAX handler for an "render_admin_charts_page" request, you would create a hook like this: add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' ); function yourfunction() { ?> <div class="wrap"> <div class="em-bookings-events"> ...



Top 50 recent answers are included