I'm working on a multisite, everything is configured and works fine from dashboard. Now I'm trying to write a plugin with a PHP file that displays the list of pages created in a site - to be displayed to the admin of the site who logs in.
Here is the code (simplified)
<?php
require('../../../wp-load.php');
?>
(some HTML)
<?php
$pages = get_pages();
foreach ( $pages as $page ) {
echo $page->post_title . '<br>'
?>
My plugin PHP file uses login_redirect
filter to redirect user after login to that PHP file where I am trying to display the list of pages the user created:
function my_login_redirect( $redirect_to, $request ) {
return '/wp-content/plugins/my-admin-plugin/my-admin-view-all-pages.php';
}
THE PROBLEM - no matter which site I'm in, I get the list of pages created in the "main" site. How do I pass the context of the existing site to the functions?
wp-load.php
? That shouldn’t be necessary.