Admin-Ajax Error

You need to pass the values to the localization script, “right” after this line: wp_enqueue_script(‘rnm_load_more’); I’m going to pass the admin URL to your script by using wp_localize_script: $localization = array( ‘ajax_url’ => admin_url(‘admin-ajax.php’), ); wp_localize_script( ‘rnm_load_more’, ‘jjang’, $localization ); Now, you can use the ajax_url in your script: var ajaxurl = rnm_load_more.ajax_url; You can … Read more

How to send Ajax request from my plugin in admin dashboard?

Here’s a base snippet I use for AJAX submits in WordPress. It does use jQuery, but there’s no reason vanilla won’t work. You could admin_enqueue_scripts() the <script>, and conditionalize it on the proper page with get_current_screen(). add_action( ‘admin_menu’, function(){ add_menu_page( ‘My Plugin’, ‘My Plugin’, ‘manage_options’, ‘my_plugin_slug’, ‘my_plugin_page’, ‘dashicons-cloud’ ); }); function my_plugin_page() { if (isset($_POST[‘my_plugin_ajax_submit’])) … Read more

How to load content from many posts on a page, only if needed

You could use LazyLoading too, just put the URL for the image in a data-src attribute in the element <img/>, then on click your anchor, copy the data there to the src attribute. Maybe your lightbox plugin offers an event or config option to put your handler, using jQuery I’d use something like this: $(‘a.load-lightbox’).click(function(e) … Read more