Answer the question
In order to leave comments, you need to log in
How to create a simple link handling rule in Wordpress?
Good afternoon
I have a simple one page landing page in Wordpress.
Landing page navigation is done using anchors #
I need to make Wordpress treat the transition to a specific page as a transition to an anchor.
That is, if the user enters the site.ru/contact page, then the site.ru/index.php#contact page is shown to him
Without redirects and without changing the URL - so that the user thinks that he is on the site.ru/contact page
From the documentation According to Wordpress, it's not at all clear to me how this can be achieved.
Options I have tried:
add_action( 'init', 'custom_rewrite_basic' );
function custom_rewrite_basic() {
add_rewrite_rule( '^(contact)', 'index.php#$matches[1]', 'top' );
}
add_action( 'init', 'custom_rewrite_basic' );
function custom_rewrite_basic() {
add_rewrite_rule( '^(/contact)', 'index.php#$matches[1]', 'top' );
}
add_action( 'init', 'custom_rewrite_basic' );
function custom_rewrite_basic() {
add_rewrite_rule( '^(index.php)/([^&]+)', 'index.php#$matches[2]', 'top' );
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question