XMLHttpRequest of admin data to public

I have a function that get the data from a admin page and display the result at frontpage. But only works when admin user is logged in. How can I display the result even if user is not logged in?

Here the code in apoiadores.js `xhr.open(“GET”, “http://localhost/editora/wp-admin/edit.php?post_type=shop_order“);

xhr.addEventListener(“load”, carregarapoiadores);
xhr.addEventListener(“load”, preco); `

and here the code in functions.php `function apoiadores () {
wp_enqueue_script(‘apoiadores’, get_template_directory_uri() . ‘/chsv/js/apoiadores.js’, array(‘jquery’), ”, true);

}
add_action(‘wp_enqueue_scripts’, ‘apoiadores’);

function prazo () {
wp_enqueue_script(‘prazo’, get_template_directory_uri() . ‘/chsv/js/prazofinal.js’, array(‘jquery’), ”, true);

}
add_action(‘wp_enqueue_scripts’, ‘prazo’);`

Read more here:: XMLHttpRequest of admin data to public

Leave a Reply

Your email address will not be published. Required fields are marked *