最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

menus - Add custom page link with anchor

programmeradmin5浏览0评论

In my admin section I would like to add in Appearance > Menus > some custom pages to add to my menu. I have two different menu one for the home page and one for the others pages. In my home page menu I add the menu elements as link because I need to give to the href the id of html element so i can 'redirect' in a specific point in my page, so my link is '#gallery'. In the menù for all the other page I the link should be 'http://my_domain/home/#gallery. Is there a way to add dinamically this link to the page list? I hope I was clear. Thanks

In my admin section I would like to add in Appearance > Menus > some custom pages to add to my menu. I have two different menu one for the home page and one for the others pages. In my home page menu I add the menu elements as link because I need to give to the href the id of html element so i can 'redirect' in a specific point in my page, so my link is '#gallery'. In the menù for all the other page I the link should be 'http://my_domain/home/#gallery. Is there a way to add dinamically this link to the page list? I hope I was clear. Thanks

Share Improve this question asked May 10, 2015 at 18:06 TWONEKSONETWONEKSONE 1511 gold badge1 silver badge3 bronze badges 4
  • I have just added a Custom Link menu item, href is example/contact/#content and when I am in the contact page, the menu item works fine, in terms of jumping to content using the ID of the division without reloading the page.. – Ismail Commented May 10, 2015 at 18:38
  • I'm developing in local so my custom link will be localhost/folder_name/home/#content. If I just add the link when I'll deploy my blog I will need to change all this link. I'm looking for a dynamic method to do that. – TWONEKSONE Commented May 11, 2015 at 8:08
  • Then add only /home/#content as a link.. – Ismail Commented May 12, 2015 at 21:52
  • Best plugin to do exactly that: github/wikiwyrhead/wordpress-dynamic-menu-anchor – Arnel Go Commented Mar 8 at 13:57
Add a comment  | 

2 Answers 2

Reset to default 1

I was searching for an answer for this but suddenly I got the idea and it works!

In the menu settings just add the anchor link just like an html link code <a href="#anchor" >titulo </a>

So with WP is the same but only adding the anchor in the field link

This will create the same anchor on every page to link a section which is active also en every single page, this could be a contact form, sign up, suscribe form, etc.

So this will be addressed like http://domain/postID/#sugerir

What happen on pages where this anchor won't work or is not needed?

You can hide the navigation-item with css depending on each case For me is important on every single post to link a form to suggest ideas (Sugiere un tema).

Go to the custom link tab, and in the url box just add: ?page_id=[id_number]#[anchor]

That's what worked for me after a little playing around. Make sure WordPress doesn't add http:// before it.

Other thoughts: Would be nice if WordPress just had an extra box to go with the pages where you could just paste in the anchor.

发布评论

评论列表(0)

  1. 暂无评论