Add Ajax loaded posts to existing posts

The jQuery .html and .load() is replacing the entire content. First, move your #Pagination outside of the ul.list-group. You will want this to continue to remain at the bottom of the list. Next, you will need to reconfigure your jQuery ajax to load the posts differently. You should load the posts from the next page, … Read more

Trying to send AJAX data to WordPress hook

Untested but … You need to pass your “action” identifier with the data, like so: var data = { ‘action’: ‘my_action’, ‘whatever’: 1234 }; In your case, that action would be get_number_of_promos. The example is from the Codex page about AJAX, which you should read carefully: https://codex.wordpress.org/AJAX_in_Plugins

Get Page Type (Category/Tag) Using AJAX

One thing you could do is set a variable in the archive.php like <script>var isArchive = true;</script>. Or in any template do if (is_archive()) { /* set the variable */ }. And then in the JS file do if (typeof isArchive != ‘undefined’) { } but there are probably way more elegant solutions that I’m … Read more

Know which script/page is being called by ajax call

Open the website with Web Developer tools or Browser inspection tools ( Firebug )etc and then Run “Console”. Refresh your website and see the Ajax calls. Check the POST window in Ajax call to see action script. That’d tell you the exact function being called.

Simulate a specific page when making AJAX calls

The issue turned out to be elsewhere. But I did learn that there is no way to overwrite the queried URL directly, as it comes from $_SERVER variables. The answer here had some code for anyone who wants to do that: https://stackoverflow.com/questions/10739721/wordpress-ajax-parse-url

WordPress Get Header and Footer using in Admin Area

A very simple experiment… add_action(‘admin_init’,’get_header’); add_action(‘admin_init’,’get_footer’); … will demonstrate that the get_header() and get_footer() functions work on the back end as well as the front, though you will need to adjust for numerous markup problems and other issues. Honestly, you question seems to be “how do I get the site header and footer and use … Read more