In your login link you call the WordPress function wp_login_url()
to generate the login URL. Mr Peattie’s question in the comments refers to the documented parameter redirect
supported by this function. When in doubt, always check the documentation: https://developer.wordpress.org/reference/functions/wp_login_url/
There are actually two parameters for wp_login_url()
but for the purpose of your question, the first one is all you need to provide.
Making use of the redirect
parameter will tell WordPress where to send a user that completes login successfully. Assuming your link to the login form is coming from a template for the About Us page that you wish to return to, the current page permalink can be used as the value for the parameter like this:
wp_login_url( get_permalink() )
Look at the output of that command and you will see the query parameter on the login URL that is output by WordPress.
If you are using the login URL function somewhere else and need the About Us page as the redirect target, simply enter it as a string, like this:
wp_login_url( '/about-us' ) )
For a better user experience, check the current user’s login status before showing the login link. Putting that together with the rest of your code:
<?php if ( ! is_user_logged_in() ) : ?>
<p>You need to be logged in in order to view this content. Would you like to <a href="<?php echo esc_url( wp_login_url( '/about-us' ) ); ?>"><?php _e('log in') ?></a> now?</p>
<?php endif; ?>