I want the Title of page/post to show up topmost when reading the post/page

To ensure the title of the page or post is displayed at the top when linked with an anchor, you need to adjust the HTML structure of your WordPress theme slightly. The title should be placed within an anchor element that can be targeted.

Step-by-Step Guide to Link Directly to the Title of a Post/Page

1. Modify the Theme Template

  1. Access Theme Files:

    • Connect to your WordPress installation via FTP or use the theme editor in the WordPress admin dashboard.
    • Navigate to the theme directory (typically wp-content/themes/your-theme).
  2. Edit the Single Post/Page Template:

    • Locate the template file for single posts (single.php) or pages (page.php). You may also want to edit header.php if your theme uses a header file for the title.
  3. Add an ID to the Title:

    • Open the single.php or page.php file in a text editor.

    • Find the code that displays the title, which usually looks something like this:

      <h1 class="entry-title"><?php the_title(); ?></h1>
      
    • Add an id attribute to the title element:

      <h1 class="entry-title" id="post-title"><?php the_title(); ?></h1>
      
  4. Save and Upload the Modified Template:

    • Save the changes to the template file.
    • If you edited the file locally, upload it back to the theme directory on your server.

2. Use the Anchor Link

  • When you want to link directly to the title of a specific post or page, use the anchor #post-title in your URL.
  • For example, if the URL of your post is https://example.com/my-post, you can link directly to the title with https://example.com/my-post#post-title.

Example:

If your post URL is:

https://example.com/my-post

The link to the title will be:

https://example.com/my-post#post-title