Wordpress: How to show a link only on a specific page










0














I have created my website in WordPress which has four links as follows:



HOME | CONTACT | GET FREE QUOTE | ABOUT


The "GET FREE QUOTE" link only works on my home page because it's pointing to the id of my "get free quote" section of the page



<a href="#quote"> GET FREE QUOTE </a>


At the bottom of my home page, I have a section with an id of "quote" so when I click on "get free quote" link I am taken to that section. So it's unnecessary to show it on other pages of my website. I tried searching on google but I didn't find the solution.



my site http://cashforcarsbrizbane.com/










share|improve this question




























    0














    I have created my website in WordPress which has four links as follows:



    HOME | CONTACT | GET FREE QUOTE | ABOUT


    The "GET FREE QUOTE" link only works on my home page because it's pointing to the id of my "get free quote" section of the page



    <a href="#quote"> GET FREE QUOTE </a>


    At the bottom of my home page, I have a section with an id of "quote" so when I click on "get free quote" link I am taken to that section. So it's unnecessary to show it on other pages of my website. I tried searching on google but I didn't find the solution.



    my site http://cashforcarsbrizbane.com/










    share|improve this question


























      0












      0








      0







      I have created my website in WordPress which has four links as follows:



      HOME | CONTACT | GET FREE QUOTE | ABOUT


      The "GET FREE QUOTE" link only works on my home page because it's pointing to the id of my "get free quote" section of the page



      <a href="#quote"> GET FREE QUOTE </a>


      At the bottom of my home page, I have a section with an id of "quote" so when I click on "get free quote" link I am taken to that section. So it's unnecessary to show it on other pages of my website. I tried searching on google but I didn't find the solution.



      my site http://cashforcarsbrizbane.com/










      share|improve this question















      I have created my website in WordPress which has four links as follows:



      HOME | CONTACT | GET FREE QUOTE | ABOUT


      The "GET FREE QUOTE" link only works on my home page because it's pointing to the id of my "get free quote" section of the page



      <a href="#quote"> GET FREE QUOTE </a>


      At the bottom of my home page, I have a section with an id of "quote" so when I click on "get free quote" link I am taken to that section. So it's unnecessary to show it on other pages of my website. I tried searching on google but I didn't find the solution.



      my site http://cashforcarsbrizbane.com/







      php html wordpress






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 at 9:20









      Sam Walpole

      637




      637










      asked Nov 12 at 7:03









      Rida Batool

      115




      115






















          3 Answers
          3






          active

          oldest

          votes


















          1














          For the other pages you don't provide the entire link destination of the section. In order to fix that link you have to add the url address of the page too, so:



          <a href="#quote"> GET FREE QUOTE </a>


          You should change to:



          <a href="http://cashforcarsbrizbane.com/#quote"> GET FREE QUOTE </a>


          If you use a custom template for the homepage then your code should be:



          <a href="<?php echo esc_url( home_url( '/' ) ); ?>#quote"> GET FREE QUOTE </a> 


          To understand better if the quote was in the contact page, for example, the link's destination must have the page where you created the #quote section, and code will be:



          <a href="http://cashforcarsbrizbane.com/contact/#quote"> GET FREE QUOTE </a>

          <a href="<?php echo esc_url( home_url( '/contact' ) ); ?>#quote"> GET FREE QUOTE </a>





          share|improve this answer




















          • yeah it seems right . but can i hide it if i want ?
            – Rida Batool
            Nov 12 at 7:42










          • From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
            – Ovidiu Barzaghideanu
            Nov 12 at 8:05



















          0














          You should your "GET FREE QUOTE" code at the footer section with if condition as:



          <?php
          global $post;
          $post_slug=$post->post_name;//returns page slug name
          $pages_array = array("home","about","conatact");//you can add or remove pages names
          if(in_array($post_slug,$pages_array))

          // put get free quote here






          share|improve this answer




























            0














            You can do it easily by using a plugin name if-menu. It will help you to select some logic in Menu Option. Please check the link. You can find a Option named Front Page, you make your menu item visible for Front Page only.



            Hope this helps.






            share|improve this answer
















            • 1




              While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
              – DarkMukke
              Dec 4 at 13:03










            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%2f53257286%2fwordpress-how-to-show-a-link-only-on-a-specific-page%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            3 Answers
            3






            active

            oldest

            votes








            3 Answers
            3






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            For the other pages you don't provide the entire link destination of the section. In order to fix that link you have to add the url address of the page too, so:



            <a href="#quote"> GET FREE QUOTE </a>


            You should change to:



            <a href="http://cashforcarsbrizbane.com/#quote"> GET FREE QUOTE </a>


            If you use a custom template for the homepage then your code should be:



            <a href="<?php echo esc_url( home_url( '/' ) ); ?>#quote"> GET FREE QUOTE </a> 


            To understand better if the quote was in the contact page, for example, the link's destination must have the page where you created the #quote section, and code will be:



            <a href="http://cashforcarsbrizbane.com/contact/#quote"> GET FREE QUOTE </a>

            <a href="<?php echo esc_url( home_url( '/contact' ) ); ?>#quote"> GET FREE QUOTE </a>





            share|improve this answer




















            • yeah it seems right . but can i hide it if i want ?
              – Rida Batool
              Nov 12 at 7:42










            • From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
              – Ovidiu Barzaghideanu
              Nov 12 at 8:05
















            1














            For the other pages you don't provide the entire link destination of the section. In order to fix that link you have to add the url address of the page too, so:



            <a href="#quote"> GET FREE QUOTE </a>


            You should change to:



            <a href="http://cashforcarsbrizbane.com/#quote"> GET FREE QUOTE </a>


            If you use a custom template for the homepage then your code should be:



            <a href="<?php echo esc_url( home_url( '/' ) ); ?>#quote"> GET FREE QUOTE </a> 


            To understand better if the quote was in the contact page, for example, the link's destination must have the page where you created the #quote section, and code will be:



            <a href="http://cashforcarsbrizbane.com/contact/#quote"> GET FREE QUOTE </a>

            <a href="<?php echo esc_url( home_url( '/contact' ) ); ?>#quote"> GET FREE QUOTE </a>





            share|improve this answer




















            • yeah it seems right . but can i hide it if i want ?
              – Rida Batool
              Nov 12 at 7:42










            • From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
              – Ovidiu Barzaghideanu
              Nov 12 at 8:05














            1












            1








            1






            For the other pages you don't provide the entire link destination of the section. In order to fix that link you have to add the url address of the page too, so:



            <a href="#quote"> GET FREE QUOTE </a>


            You should change to:



            <a href="http://cashforcarsbrizbane.com/#quote"> GET FREE QUOTE </a>


            If you use a custom template for the homepage then your code should be:



            <a href="<?php echo esc_url( home_url( '/' ) ); ?>#quote"> GET FREE QUOTE </a> 


            To understand better if the quote was in the contact page, for example, the link's destination must have the page where you created the #quote section, and code will be:



            <a href="http://cashforcarsbrizbane.com/contact/#quote"> GET FREE QUOTE </a>

            <a href="<?php echo esc_url( home_url( '/contact' ) ); ?>#quote"> GET FREE QUOTE </a>





            share|improve this answer












            For the other pages you don't provide the entire link destination of the section. In order to fix that link you have to add the url address of the page too, so:



            <a href="#quote"> GET FREE QUOTE </a>


            You should change to:



            <a href="http://cashforcarsbrizbane.com/#quote"> GET FREE QUOTE </a>


            If you use a custom template for the homepage then your code should be:



            <a href="<?php echo esc_url( home_url( '/' ) ); ?>#quote"> GET FREE QUOTE </a> 


            To understand better if the quote was in the contact page, for example, the link's destination must have the page where you created the #quote section, and code will be:



            <a href="http://cashforcarsbrizbane.com/contact/#quote"> GET FREE QUOTE </a>

            <a href="<?php echo esc_url( home_url( '/contact' ) ); ?>#quote"> GET FREE QUOTE </a>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 12 at 7:30









            Ovidiu Barzaghideanu

            863




            863











            • yeah it seems right . but can i hide it if i want ?
              – Rida Batool
              Nov 12 at 7:42










            • From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
              – Ovidiu Barzaghideanu
              Nov 12 at 8:05

















            • yeah it seems right . but can i hide it if i want ?
              – Rida Batool
              Nov 12 at 7:42










            • From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
              – Ovidiu Barzaghideanu
              Nov 12 at 8:05
















            yeah it seems right . but can i hide it if i want ?
            – Rida Batool
            Nov 12 at 7:42




            yeah it seems right . but can i hide it if i want ?
            – Rida Batool
            Nov 12 at 7:42












            From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
            – Ovidiu Barzaghideanu
            Nov 12 at 8:05





            From the menu options you can hide a link if you add a custom css class, for example hide-menu-item, but you have to create that class in your style.css file .hide-menu-itemdisplay:none An easy solution will be to remove it. Also please mark my answer as the good one. Thanks
            – Ovidiu Barzaghideanu
            Nov 12 at 8:05














            0














            You should your "GET FREE QUOTE" code at the footer section with if condition as:



            <?php
            global $post;
            $post_slug=$post->post_name;//returns page slug name
            $pages_array = array("home","about","conatact");//you can add or remove pages names
            if(in_array($post_slug,$pages_array))

            // put get free quote here






            share|improve this answer

























              0














              You should your "GET FREE QUOTE" code at the footer section with if condition as:



              <?php
              global $post;
              $post_slug=$post->post_name;//returns page slug name
              $pages_array = array("home","about","conatact");//you can add or remove pages names
              if(in_array($post_slug,$pages_array))

              // put get free quote here






              share|improve this answer























                0












                0








                0






                You should your "GET FREE QUOTE" code at the footer section with if condition as:



                <?php
                global $post;
                $post_slug=$post->post_name;//returns page slug name
                $pages_array = array("home","about","conatact");//you can add or remove pages names
                if(in_array($post_slug,$pages_array))

                // put get free quote here






                share|improve this answer












                You should your "GET FREE QUOTE" code at the footer section with if condition as:



                <?php
                global $post;
                $post_slug=$post->post_name;//returns page slug name
                $pages_array = array("home","about","conatact");//you can add or remove pages names
                if(in_array($post_slug,$pages_array))

                // put get free quote here







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 at 7:49









                Gufran Hasan

                3,42641326




                3,42641326





















                    0














                    You can do it easily by using a plugin name if-menu. It will help you to select some logic in Menu Option. Please check the link. You can find a Option named Front Page, you make your menu item visible for Front Page only.



                    Hope this helps.






                    share|improve this answer
















                    • 1




                      While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                      – DarkMukke
                      Dec 4 at 13:03















                    0














                    You can do it easily by using a plugin name if-menu. It will help you to select some logic in Menu Option. Please check the link. You can find a Option named Front Page, you make your menu item visible for Front Page only.



                    Hope this helps.






                    share|improve this answer
















                    • 1




                      While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                      – DarkMukke
                      Dec 4 at 13:03













                    0












                    0








                    0






                    You can do it easily by using a plugin name if-menu. It will help you to select some logic in Menu Option. Please check the link. You can find a Option named Front Page, you make your menu item visible for Front Page only.



                    Hope this helps.






                    share|improve this answer












                    You can do it easily by using a plugin name if-menu. It will help you to select some logic in Menu Option. Please check the link. You can find a Option named Front Page, you make your menu item visible for Front Page only.



                    Hope this helps.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 12 at 8:25









                    Tristup

                    2,7361721




                    2,7361721







                    • 1




                      While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                      – DarkMukke
                      Dec 4 at 13:03












                    • 1




                      While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                      – DarkMukke
                      Dec 4 at 13:03







                    1




                    1




                    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                    – DarkMukke
                    Dec 4 at 13:03




                    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
                    – DarkMukke
                    Dec 4 at 13:03

















                    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.





                    Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                    Please pay close attention to the following guidance:


                    • 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%2f53257286%2fwordpress-how-to-show-a-link-only-on-a-specific-page%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







                    這個網誌中的熱門文章

                    Barbados

                    How to read a connectionString WITH PROVIDER in .NET Core?

                    Node.js Script on GitHub Pages or Amazon S3