random post redirect php code


 add_action('template_redirect', function () {

    if (strpos($_SERVER['REQUEST_URI'], '/studetns-h') !== false) {


        // Disable cache to ensure randomness

        header("Cache-Control: no-cache, no-store, must-revalidate");

        header("Pragma: no-cache");

        header("Expires: 0");


        $links = [

            "https://careers.blepie.online/sassa-status-check-students-r370/",

            "https://careers.blepie.online/learnerships-for-matriculants-2026/",

            "https://careers.blepie.online/colleges-open-late-applications-2026/",

            "https://careers.blepie.online/nsfas-online-application-login/",

            "https://careers.blepie.online/matric-results-check-online/"

        ];


        // Pick random link

        $random_link = $links[array_rand($links)];


        // Redirect

        wp_redirect($random_link);

        exit;

    }

});



No comments:

Post a Comment

Pages