New answers tagged

2

After Milo's tutorship: I recommend first reading how to use AJAX in Plugins properly. – Milo yesterday and reading another questions on wp.stack, my problem was solved) Here is an examples of code from my rewritten files 1)get_state.php: ad add_action( 'wp_ajax_ajax_object', 'ajax_handler' ); add_action( 'wp_ajax_nopriv_ajax_object', ...


1

Try this, with " tags on .= '<a href="'.get_permalink($id).'"><img src="'.$image['url'].'" /></a>';


2

No no no! Never POST or link directly to a custom PHP file - WordPress won't be loaded, and to load it manually yourself means making huge assumptions about the file hierarchy. Use the ajax API, which exists specifically for this reason: $.ajax({ url: "<?php echo esc_js( admin_url( 'admin-ajax.php' ) ) ?>", type: "POST", data: { ...


0

Make sure you set your define( 'WP_DEBUG', false ); Else the notices and possible errors may cause 404.


0

Make sure you set your define( 'WP_DEBUG', false ); Else you may get 404. In my case I had that problem, when I inherited some project where there was many notices, and PHP warnings. This may be connected with the Ajax problem I had at that time. The temporary solution was to set debugging to false in my case.


0

That's called Thickbox. Since you give no clue what you want to use it for, you'll have to figure out the rest for yourself...


1

the_content is usually "executed" in the context of a loop when all relevant global data is set. You should try to mimic it by using code like function get_page_content(){ global $post; $id = $_REQUEST['id']; $post = get_page($id); setup_postdata($post); echo apply_filters('the_content', $post->post_content); //echo ...


0

You should consider giving the Ajax Load More WordPress plugin a try. https://wordpress.org/plugins/ajax-load-more/


0

Your first problem is that your AJAX function in functions.php should echo its results, not return. You also need a call to wp_die() at the end. I'm not completely sure what you are trying to do but it looks like half of your loop probably shouldn't be there. Currently you are outputing the whole #ajaxx list inside itself every time you click #load-more. ...


0

This will (*should) fix your first problem: function rmcc_post_listing_shortcode1( $atts ) { // No need for output buffering - AJAX handlers should ECHO their response // ob_start(); // .. // So long, farewell // $myvariable = ob_get_clean(); // return $myvariable; // Now terminate exit; } Your second problem is that you ...


0

You could create your own email_exists function to check it in a different way, I ended up doing this in a plugin as I was not getting consistent results with email_exists for some reason: function check_email_exists($email) { global $wpdb; $user_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".$wpdb->users." WHERE user_email = ...


1

Why are you making work hard for yourself? wp_create_user already checks if the email/login exists, which is also why your code is "failing" - $user_id will already be a WP_Error, so your elseif ( is_wp_error( $newerrors ) ) never fires. All you need is: $user_id = wp_create_user( $sanitized_user_login, $user_pass, $user_email, $capa ); if ( is_wp_error( ...


0

You ajax logic seems okay.. In order to solve a duplication problem you need to add a flag. Example: var isLoading = false; -- Your click event is here -- // Only let things to happen if there's no ajax in the middle of process if( isLoading == false ) { // Set it to true - now nothing happens if you click it again isLoading = true; -- All ...


0

You might want to load all the items on the page at the same time, and use jQuery to display however many at a time. So for example: By default you could load (to the DOM) and hide all of them, then load 4 at a time using jQuery's slice Here's an example for my videos, however you could also hide the previous 4 videos before loading the next 4 to simulate ...


0

I looked into doing the same thing and in the end opted for a custom solution using thickbox as being less complex. Could be it's possible, but perhaps not worth the effort. The code is certainly not built for customisation as far as I could see. Open a thickbox modal with a search field Ajax search the post title with the user-entered search term Echo the ...



Top 50 recent answers are included