Shortcode to pull posts

UPDATE Turns out the issue was with the first page of posts. I needed to account for page 1 when calling the ajax load more. Since this is a shortcode and not a template my query vars were not passing along to the ajax call. I resolved the issue by passing the page as a … Read more

How to use the wpsnonce clone post link?

One option is to use wp_add_inline_script() to inline the action url to the page source. This can be done for example on the admin_enqueue_scripts action. In the example below I used admin_url() with wp_nonce_url() to retrieve the nonce wp-admin url and then added the query paramters to it with add_query_arg(). add_action( ‘admin_enqueue_scripts’, ‘my_admin_action_url’, 5 ); … Read more

WordPress Menu adds an unwanted slash before anchor

You can likely change that by removing the slash from the end of the permalink structure on wp-admin/options-permalink.php & you should be good to go. But as Krzysiek Dróżdż has said: It shouldn’t make a difference in the execution of javaScript & trailing slashes are a best-practaice.

wp_mail doesn’t work when logged in?

You’ve got a typo in the hook that runs for logged in users: add_action(‘wp_ajax_search_notify_emaill’, ‘search_notify_email’); There’s an extra l in the hook name. The hook names need to be the same, apart from nopriv_, so you should have: add_action(‘wp_ajax_nopriv_search_notify_email’, ‘search_notify_email’); add_action(‘wp_ajax_search_notify_email’, ‘search_notify_email’); When you send an AJAX request with an action WordPress runs the hook … Read more

jQuery Ajax PHP function call returning [object Object]

OK, so there are multiple problems with your code… 1. Incorrect localization of script Here’s your function that enqueues and localizes the scripts: function my_theme_enqueue_scripts() { wp_enqueue_script(‘jquery-ui’, ‘https://code.jquery.com/ui/1.12.1/jquery-ui.min.js’, array(‘jquery’), ‘1.12.1’); wp_register_script( ‘myjs’, get_stylesheet_directory_uri() . ‘/my.js’, array(‘jquery’),’1.0.0′); wp_enqueue_script(‘myjs’); wp_localize_script( ‘ajax-script’, ‘admin-ajax’, array( ‘ajax_url’ => admin_url( ‘admin-ajax.php’ ) ) ); } add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_scripts’ ); So you … Read more

My jQuery Ajax form submit is still refreshing page?

You use wrong js event. You register your callback with this code: $(‘#form-pm’).on(‘send’, function(e) { But there is no event called send on form. It should be submit. Here’s fixed version of that line: $(‘#form-pm’).on(‘submit’, function(e) {