Wordpress: How to show a link only on a specific page
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
add a comment |
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
add a comment |
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
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
php html wordpress
edited Nov 12 '18 at 9:20
Sam Walpole
787
787
asked Nov 12 '18 at 7:03
Rida BatoolRida Batool
115
115
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
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>
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 at 8:05
add a comment |
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
add a comment |
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.
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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>
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 at 8:05
add a comment |
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>
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 at 8:05
add a comment |
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>
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>
answered Nov 12 '18 at 7:30
Ovidiu BarzaghideanuOvidiu Barzaghideanu
863
863
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 at 8:05
add a comment |
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 at 8:05
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 at 7:42
yeah it seems right . but can i hide it if i want ?
– Rida Batool
Nov 12 '18 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 '18 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 '18 at 8:05
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 12 '18 at 7:49
Gufran HasanGufran Hasan
3,54141326
3,54141326
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Nov 12 '18 at 8:25
TristupTristup
2,7891721
2,7891721
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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