• Is there a way to show the username in the page title?

    So for example:
    Welcome! (for not logged in users)
    Welcome David! (for the logged in user David)

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there

    I think this article might be of help… https://www.seoptimer.com/blog/wordpress-page-title/

    While I haven’t tested this myself, it looks like it would work to me.

    But when editing files, ALWAYS ALWAYS take a back-up first.

    Thread Starter woltersthijs

    (@woltersthijs)

    @nekojonez

    Thanks for your quick response! The item just doesn’t meet what I want. I would like to change one page title with the logged in username, preferably with a shortcode or something similar.

    Moderator bcworkz

    (@bcworkz)

    Shortcodes will not work within titles without some extra coding. You may as well do the extra coding without involving shortcodes. The solution depends on how your theme outputs titles. If you theme uses the_title(), you can use “the_title” filter hook to alter the title in any manner you like.

    You can get the current user’s object with wp_get_current_user(). All the various names can be gotten from the user object. Exactly how depends on which name. There is login name, nice name, display name, and various meta data names.

    If you only wish to change the title on a specific page, the current post ID is passed as a second parameter for “the_title”.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Username in pagetitle’ is closed to new replies.