get_body_class() in ajax envrionment

You are probably trying to do something wrong. Templating functions require context with global query and post variables properly set, and even then you might miss all kinds of filters because ajax requests are not being run in the context of template evaluation which means that template_redirect, wp_head and others are not being “run” which … Read more

How to force the admin-ajax.php file to load over HTTPS?

If you are using Domain Mapping plugin doing this will quickly achieve exactly what you are asking for. Go to: YOURDOMAIN/wp-admin/tools.php?page=domainmapping Under: Excluded pages, check: Force SSL for all pages. Save and you’re done. Your insecure mixed content error due to admin-ajax.php loading via http instead of via https should be gone after this.

Create a post with REST API and adding a category

Solution was simple. Set DOM element value in JS variable instead of “document.getElementById(‘post_category’).value” in array. var submitBtn = document.getElementById(‘submit-post-btn’); submitBtn.addEventListener(‘click’, function(){ var categoryTerm = document.getElementById(‘post_category’).value; var postData = { “title”: document.getElementById(‘post_title’).value, “content”: document.getElementById(‘post_content’).value, “status”: ‘publish’, “categories”: [categoryTerm] } };

Create secondary Archive page format?

You could copy the contents of your current archive page file into a new file, then tweak the functionality there into what you need it to do. At the top of the file, give it a template name like this: /* Template Name: Short Archive */ Now you can create a new page and select … Read more

Ajax by worpdress affects called jquery inside template file

This will not work: function widget_data(){ include get_template_directory() . ‘/inc/wid/card/widget-card.php’; wp_die(); } The include statment includes the “widget-card.php” only into the file and not the output stream. You have to redirect the output into a variable and then output the value via “echo”. function widget_data(){ ob_start(); include get_template_directory() . ‘/inc/wid/card/widget-card.php’; $output = ob_get_clean( ); echo … Read more

WordPress 4.9.6 – IncludeMe & getAjax GET using wrong URL

If I run a curl command: curl ​https://theprepared.life/data/earthquakes-today.json I get back the json object correctly. So your server work properly. So unless from a different origin, when you running $.getJSON() call, you only need to submit data/earthquakes-today.json as the url, instead of the entire url, which caused the 404 error. $.getJSON(“data/earthquakes-today.json”, function(data) { // rest … Read more

How to send the checkbox value to email

First you need to add a class for all checkbox as having same id for multiple items is not recommended <input type=”checkbox” class=”new_class” id=’haet_mail_test_address’ name=”ckboxs[]” value=””.$emails[$i][“user_email’].”‘> Now we to change the way you are getting the values from checkbox Change var checkbox = $(‘#haet_mail_test_address’).val(); To var checkbox = $(“.new_class:checkbox:checked”).map(function(){ return $(this).val(); }).get(); console.log(checkbox); // check … Read more