目次
At first
In WordPress, there are times when you want to jump directly to the location of the article instead of jumping to the top of the page after the link. For example, when you want users to see the article immediately, but the title image or advertisement at the top of the page is thick, so the article is not displayed on the screen immediately after the link. Even though the article is meaningful, the user who was first shown only the title image or advertisement may just close the browser. As a user-friendly response, you may be able to prevent such users from leaving by automatically scrolling the screen to the location of the article after the link.
Method
It’s easy to do. Just add “#content” to the end of the URL that indicates the post or the page, as shown below.
<a href="https://example.com/archives/1234#content">Link Text</a>
When inserting a link with the editor function of WordPress, add “#content” to the end of the link destination URL as shown below.
When setting the link in the menu, specify the URL using a custom link as shown below, instead of selecting and setting the post or the page.
Principle
Why does setting a link like this take you directly to the article?
If you add “#xxx” to the end of the URL of the link destination in HTML, you can instruct the browser to jump to the block with the id of “xxx”. Here, in a general WordPress page, the id “content” is specified for the content block. The content of a post or a page is an article. Therefore, if you add “#content” to the link destination, you will instruct the browser to jump directly to the article.
Supplement
Depending on your WordPress theme, the article block id may not be “content”. In that case, you can handle it by reading the code on the page, searching for the appropriate id, and specifying that id.
To view the page code in Chrome, simply select “View page source” from the page’s right-click menu.