Including ‘wp-load.php’ after another include() generates an error
A different way of fixing it: function load_wp(){ global $wpdb; include_once(‘wp-load.php’); }
A different way of fixing it: function load_wp(){ global $wpdb; include_once(‘wp-load.php’); }
I dont think it is possible to do this by using the contact form 7 plugin. Because the plugin uses bind(‘click’) on the submit button JS trigger, where it supposed to be live(‘click’) to work on an AJAX loaded form. As an alternative you can use a custom made contact form, or hide the contact … Read more
I didn’t test anything, but I imagine it would be something like this: As you must include a sidebar.php, just include an empty sidebar.php, and leave the real one to the sidebar-ajax.php, for example. To call the sidebar: <?php get_template_part(‘sidebar’); ?> And it should be something like this: <div id=”sidebar”></div> In your functions.php: add_action(‘wp_enqueue_scripts’, ‘theme_enqueue_scripts’); … Read more
add_action and add_filter always return true. And yes, in PHP, any string that is not empty or “0” is loosely equal to the boolean true. And I see nothing wrong with your die code. It’s hooked to wp_ajax_my_action, so you need to make a call to the admin-ajax.php as an authenticated user, with the my_action … Read more
Simply add a Success callback to your Ajax function: $(‘#sendEmail’).click(function(){ $.ajax({ type: ‘POST’, url: ‘www.example.com/email.php’, data: { content: $(‘#email-data’).html()}, success: function(data) { //data variable can be used if your ajax call returns something do_stuff_here(); } }); }); In your case, you could do something like success: function() { $(‘body’).append(‘<div class=”success”>Success!</div>’); } However, is there a … Read more
You should use the WP AJAX APIs rather than reinventing them in your home template, e.g.: functions.php : // declare the URL to the file that handles the AJAX request (wp-admin/admin-ajax.php) wp_localize_script( ‘my-ajax-request’, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ) ) ); add_action(‘wp_ajax_my_action’, ‘my_action_callback’); add_action(‘wp_ajax_nopriv_my_action’, ‘my_action_callback’); function my_action_callback() { $content=”something to send back to the … Read more
Based on the comment by Ralf912 I tried to find out what the console and devtools in Chrome as all about. This debugger made clear what is wrong with my script, it’s not a WordPress specific problem, but in case others think it is I’ll explain. It may be that WordPress has set up an … Read more
I don’t know if there is really a right answer to this question, and I don’t know what you find cumbersome about wp_localize_script, but you should be able to do it either way. The difference is that with wp_localize_script the data is printed to the source of the page, which you wouldn’t want if the … Read more
With the WordPress 3.6 heartbit Api this should be easier. With previous WordPress version you have to play with ajax and js setInterval() function. Edit @Daniel Foltynek suggest this plugin.
An AJAX request is a request from a client like any other request. Just request the URL like normal, but with Javascript. As far as that goes, this should be simple. If you’ve done item #2– “I’ll wrap the header/footer/sidebars…”– correctly there should be no problem except that page specific functions won’t run. That is … Read more