Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'd like to have any child page url like http://www.foo.com/fooparent/foochild automatically turns into http://www.foo.com/fooparent/#foochild

Could this be done in the htaccess rewrite rules or can I directly change the way WordPress stores the slug name so I could add # in front of it?

Use case

I have the parent pages loading all the child pages content in the template. It's utilizing a onepage layout with anchor links scrolling down the page to each section as you navigate. There are cases where permalinks of the child pages are exposed and that would break the onepage functionality. A child permalink should just load it's parent page and add use its slug as a an #anchor in the URL.

share|improve this question
    
I'm curious why you'd want this, could you edit your question to ellaborate on what your use case is? –  Tom J Nowell Apr 15 at 20:32
    
I've added a use case. Any ideas on how to do this? –  Tom Apr 15 at 20:56
    
So like a flat website design. #About would scroll down the page until it hits the 'About Page' div, correct? –  Howdy_McGee Apr 15 at 21:29
    
@howdy_McGee correct. Whenever a childpage was created, it would prepend '#' to the slug. –  Tom Apr 15 at 22:16
    
You may be looking for an HTACCESS rule instead of a WordPress work around. –  Howdy_McGee Apr 16 at 0:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.