I am creating a plugin that allows users to insert certain code on their specified page or post of their choice. I have tried doing this:
function asdf() {
$siteURL = get_site_url() . '/';
$pages = get_pages();
foreach ($pages as $page ) {
$pageTitle = get_page_link( $page->ID );
if ( $siteURL === $pageTitle ) {
echo "this is the correct page" . "<br>";
}
else {
echo "this is the wrong page". "<br>";
}
}
}
add_action('wp_head', 'asdf');
If you run this code, you will see that it treats all pages the same, and there would be no distinction in the results across different pages. However I am trying to get my function to treat each page uniquely, and give different results based on each page title.
Thanks in advance.