0

I'm working on a NON-API Wordpress site. One of the pages is a long page segmented into several sections. At the top of the page is a menu for most of the sections on the page.

When a user lands on the page, the URL will read mysite.com/about

As the user scrolls down the page, the URL updates to show the current section: mysite.com/about -> mysite.com/about/team -> mysite.com/about/awards

Inbound traffic to the page will parse the URL and scroll to the appropriate section. mysite.com/about/team will scroll to the "team" section.

All the content on the site is visible and available when the page loads, the menu only scrolls to the appropriate section. In other frameworks, this can be trivial with the History API. In WP, I've tried using the following but still get a 404

function wpd_foo_rewrite_rule() {
    add_rewrite_rule(
        '^/about/([^/]*)/?',
        'index.php?pagename=about',
        'top'
    );
}
add_action( 'init', 'wpd_foo_rewrite_rule' );
  • Have you flushed the rewrite rules - simply visit the permalink settings page? – Sally CJ Dec 12 '18 at 1:09
  • @Sally CJ excellent! It was flushing the rewrite rules as you stated. Thank you. – bresson Jan 10 '19 at 14:26
  • You're welcome, @bresson. And if a similar issue happens again - error 404 after changing the permalink structures, try to first flush the rewrite rules, because it's often be forgotten. – Sally CJ Jan 22 '19 at 0:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.