I am using Wp Store Locator plugin.And I have Modified it according my need.But I am stuck in redirection.

Basically this plugin works with short code.So at the time of listing my URL is like that : localhost/wordpress/?page_id=391

Now there is one link which is redirects me to http://localhost/wordpress/?wpsl_id=3

Here is code for that :

    add_action("template_redirect", 'my_theme_redirect');

    function my_theme_redirect() {

            $dpath = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"] ;
        $templatefilename = 'single-store.php';
        if (strpos($dpath,'wpsl_id') !== false){    
                $return_template = get_template_directory() .'/' .$templatefilename  ;
                //$nurl = get_permalink($return_template);
                //echo $return_template; exit;


This code is not redirecting me to any-where.It stays on the same page localhost/wordpress/?page_id=391 What might be the issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.