Wordpress: which function is called when user visit /?p=randomstring












0















Wordpress at the moment return a random page when visiting, for example, https://www.examplewebsite.com/?p=bdmvxmqa



At the moment it doesn't return a 404 and I'd like to correct it. But I cuouldn't find where to look into the code.










share|improve this question



























    0















    Wordpress at the moment return a random page when visiting, for example, https://www.examplewebsite.com/?p=bdmvxmqa



    At the moment it doesn't return a 404 and I'd like to correct it. But I cuouldn't find where to look into the code.










    share|improve this question

























      0












      0








      0








      Wordpress at the moment return a random page when visiting, for example, https://www.examplewebsite.com/?p=bdmvxmqa



      At the moment it doesn't return a 404 and I'd like to correct it. But I cuouldn't find where to look into the code.










      share|improve this question














      Wordpress at the moment return a random page when visiting, for example, https://www.examplewebsite.com/?p=bdmvxmqa



      At the moment it doesn't return a 404 and I'd like to correct it. But I cuouldn't find where to look into the code.







      wordpress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 9:18









      ReviousRevious

      2,5262272116




      2,5262272116
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Wordpress usually redirects to the closest matching page title. (at least it used to way back when I was working with WordPress).



          Try adding this line to functions.php to turn off this feature:



          remove_filter('template_redirect', 'redirect_canonical');  





          share|improve this answer































            1














            If this is an old URL structure then you could redirect all ?p requests to your homepage or similar with the below function:



              function rusty_redirect_query() {
            global $wp;
            $wp->add_query_var('p');
            if(get_query_var('p')) {
            wp_redirect( home_url( '/page/to/redirect/' ) );
            }
            exit();
            }
            add_action( 'template_redirect', 'rusty_redirect_query' );





            share|improve this answer























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477927%2fwordpress-which-function-is-called-when-user-visit-p-randomstring%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              1














              Wordpress usually redirects to the closest matching page title. (at least it used to way back when I was working with WordPress).



              Try adding this line to functions.php to turn off this feature:



              remove_filter('template_redirect', 'redirect_canonical');  





              share|improve this answer




























                1














                Wordpress usually redirects to the closest matching page title. (at least it used to way back when I was working with WordPress).



                Try adding this line to functions.php to turn off this feature:



                remove_filter('template_redirect', 'redirect_canonical');  





                share|improve this answer


























                  1












                  1








                  1







                  Wordpress usually redirects to the closest matching page title. (at least it used to way back when I was working with WordPress).



                  Try adding this line to functions.php to turn off this feature:



                  remove_filter('template_redirect', 'redirect_canonical');  





                  share|improve this answer













                  Wordpress usually redirects to the closest matching page title. (at least it used to way back when I was working with WordPress).



                  Try adding this line to functions.php to turn off this feature:



                  remove_filter('template_redirect', 'redirect_canonical');  






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 11:22









                  Nick SurmanidzeNick Surmanidze

                  1,113517




                  1,113517

























                      1














                      If this is an old URL structure then you could redirect all ?p requests to your homepage or similar with the below function:



                        function rusty_redirect_query() {
                      global $wp;
                      $wp->add_query_var('p');
                      if(get_query_var('p')) {
                      wp_redirect( home_url( '/page/to/redirect/' ) );
                      }
                      exit();
                      }
                      add_action( 'template_redirect', 'rusty_redirect_query' );





                      share|improve this answer




























                        1














                        If this is an old URL structure then you could redirect all ?p requests to your homepage or similar with the below function:



                          function rusty_redirect_query() {
                        global $wp;
                        $wp->add_query_var('p');
                        if(get_query_var('p')) {
                        wp_redirect( home_url( '/page/to/redirect/' ) );
                        }
                        exit();
                        }
                        add_action( 'template_redirect', 'rusty_redirect_query' );





                        share|improve this answer


























                          1












                          1








                          1







                          If this is an old URL structure then you could redirect all ?p requests to your homepage or similar with the below function:



                            function rusty_redirect_query() {
                          global $wp;
                          $wp->add_query_var('p');
                          if(get_query_var('p')) {
                          wp_redirect( home_url( '/page/to/redirect/' ) );
                          }
                          exit();
                          }
                          add_action( 'template_redirect', 'rusty_redirect_query' );





                          share|improve this answer













                          If this is an old URL structure then you could redirect all ?p requests to your homepage or similar with the below function:



                            function rusty_redirect_query() {
                          global $wp;
                          $wp->add_query_var('p');
                          if(get_query_var('p')) {
                          wp_redirect( home_url( '/page/to/redirect/' ) );
                          }
                          exit();
                          }
                          add_action( 'template_redirect', 'rusty_redirect_query' );






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 27 '18 at 15:22









                          RustyBadRobotRustyBadRobot

                          297110




                          297110






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53477927%2fwordpress-which-function-is-called-when-user-visit-p-randomstring%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Costa Masnaga

                              Fotorealismo

                              Sidney Franklin