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);
xhr.send();`
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');`
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);
xhr.send();`
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');`
The short answer is "you can't do that." The WordPress admin content requires a user be logged in to view any of the content. If this were possible, anyone could get into the admin on your site.
You will have to make this content available from the front-end by another method.