Tag Info

New answers tagged

0

ok. so your loadMore() should do something like these: function loadMore() { var showing = $('#id').find( '> .col-md-4').length; $.ajax( // making ajax call to get more images passing variable showing success: function( data ) { $('#id').append( data ); } ); } and your php (ajax) script should return ...


2

The problem could be in using admin ajax. If you switch to a different endpoint, the process may speed up. I've used ajax flow on a few sites and you should see a performance gain: https://wordpress.org/support/view/plugin-reviews/ajaxflow Check out some best practices here: https://10up.github.io/Engineering-Best-Practices/php/#libraries


-1

I got everything working but it may not be the most elegant of solutions. I put the form text as well as the empty results div on a page. I created a small plugin that checks to see if we are on that page. If so, insert the JavaScript into the footer. Otherwise, do nothing. This checks for the page we are on: public function ...


0

Your inner loop overwrites the contents of $post, so any later template tags use the values of whatever it last contained. "But I used wp_reset_postdata()!" you say? What that function does is try to restore $post from $wp_query->post. It's meant to restore the main query after secondary queries. You have two secondary queries here, so that method fails. ...


0

The JavaScript should be: <script> jQuery( document ).ready(function ( $ ) { $( "#searchform" ).on( "submit", function ( ev ) { ev.preventDefault(); $.post( "<?php echo admin_url( 'admin-ajax.php' ) ?>", { action: "wpa56343_search", ...


0

function enqueue_lazyload() { wp_enqueue_script('jquery_lazy_load', get_stylesheet_directory_uri() . '/js/jquery.lazyload.min.js', array('jquery'), '1.9.1'); } add_action('wp_enqueue_scripts', 'enqueue_lazyload'); Next, we have to add a small bit of Javascript to our footer to get the lazy load plugin to recognize images. You can see how this works on ...


0

My recommendation would be to use a plug-in like Lightbox Plus to power your link. Clicking the link would load your standard login form inside a lightbox. You could then automatically redirect to the same page so that, once logged in, users can leave a comment. Basically, you'd dynamically build your link to be something link this: <a ...


1

Before all of that, I would recommend trying Image Rotation Repair plugin.


0

I think you can do this by following way - Install the plugin https://wordpress.org/plugins/json-rest-api/ on the site from where you want to pull the posts. It makes the WordPress data available in json format. It is also possible to filter the request to get specific data. You can read the documentation in detail here at http://v2.wp-api.org Look for ...


0

I've needed to do exactly this for a plugin I'm working on and found a slightly different solution based on what Ogier did (which pointed me in the right direction thanks!) With the code provided by Ogier I found that the selected images were not appearing on top even with the extra comparitor code, so after a bit of digging around in the core and ...


0

$('#shoes-kids').on('change', function(){ $.post('<?php echo admin_url( "admin-ajax.php" ); ?>', { first_name: ""+ $("#first_name").val(), //sending first name last_name: ""+ $("#last_name").val(), //sending last name action : 'your_ajax_hook' }, function(data,status){ if(status=="success") { ...


0

also this is my class file content: <?php class Contact_Widget extends WP_Widget{ /* * Plugin Constructor */ function __construct() { parent::__construct( 'contact_widget', // Base ID __( 'Ajax Contact Widget', 'text_domain' ), // Name array( 'description' => __( 'Ajax powered contact widget', ...


0

this is my plugin content: <?php /** * Plugin Name: Ajax Contact Widget * Plugin URI: http://aliqorbani.com/plugins/contact-widget * Description: just a simple contact widget plugin. * Version: 1.0 * Author: Ali Qorbani * Author URI: http://www.aliqorbani.com * License: GPL2 */ /* * include JS */ function add_scripts(){ ...


0

var selectedValue=$(this).children(":selected").val(); Use this for getting value for select tag


2

This will not work due to the "same-origin policy" unless that server you are trying to reach specifically allows these type of requests with something like Access-Control-Allow-Origin: *. You can read the documentation on MDN in order to get more information about this topic. From my tests, the server will also need another header configured namely the ...


0

Did you try hooking a bit later? add_action('template_redirect' , 'prevent_profile_access'); References: https://codex.wordpress.org/Plugin_API/Action_Reference https://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect


1

if the request is from an unauthenticated user, you should use wp_ajax_nopriv_(action) to call the function, which in your case is: add_action('wp_ajax_nopriv_cpm_add_update', array($this,'edit_added_people'));


1

My suggesion is to use wp_localize_script() to pass the post id to your AJAX calls. Something like this.. function my_script_enqueue() { global $post; $translations = array( 'postID' => $post->ID ); wp_enqueue_script( 'myscript', '/url/to/your/script.js', array('jquery') ); wp_localize_script( 'myscript', 'MyAJAX', ...


1

As you can see, I tried declaring the $post variable as global to account for failures due to being outside of the Loop. The problem is not that the post is "outside of the loop", problem is that AJAX request is a completely separate HTTP request. When you do an AJAX request, is just like you are opening a new window on browser and open the url in ...


0

What about sending the post id of the single post trough ajax as well? So if you create a hidden input that contains the id, something like this: <input type="hidden" id="post_id" name="post_id" value="<?php echo $post->ID; ?>"> Then you can just pick the id and send it trough the ajax request, so your function will end up looking ...


0

First you need to do what Dougal said about getting the ajax-url right. I would also specify the dataType. dataType is the type of data that you're expecting back from the server, you can read more about it here. And I would use wordpress's get_template_part to get the template.


1

when ("#edit").click( is called, the element "#edit" doesn't exist so the .click( cannot be attached solution 1 you call click( juste after .innerHTML = response solution 2 use delegated event like that : $("body").on("click", "#edit", function () {...


1

So, you're using wp_localize_script to inject the ajax url. But you didn't use the localized var handle to access that value. Try this: /* ... */ $.ajax({ url: ajaxStuff.ajaxurl, // NOTE use of 'ajaxStuff' object /* ... */



Top 50 recent answers are included