How do I create a shortcode that returns a logged in users’ email?

Need to move wp_get_current_user() inside of the shortcode’s callback (untested): function current_user_email_address() { if ( ! is_user_logged_in() ) { return ”; } $user = wp_get_current_user(); if ( empty( $user->user_email ) ) { return ”; } return esc_html( $user->user_email ); } add_shortcode( ‘current_user_email_address’, ‘current_user_email_address’ );

Why Does get_page_by_path Return The Sample Post?

If the page doesn’t exist, then get_page_by_title() returns null, which when passed into get_page_link() still returns a URL, which could conceivably redirect to the sample post. Check the value of get_page_by_title() is valid before using.

all plug-ins load scripts on all pages

Most plugins will load their assets in the header on all pages, because they know very little about your site, and how you’re using the plugin. This is a reason why it’s generally advisable to use plugins only if you have to: they’re built to work for as many people as possible, which means they’re … Read more

Backup Site Data from a Bitnami WordPress instance

Bitnami support got back to my support ticket with the following response: Yes, the data that requires persistence can be found in the “/bitnami” folder. Specifically, the “/opt/bitnami/wordpress/wp-config.php” file and the “/opt/bitnami/wordpress/wp-content” directory are symbolically linked to the “/bitnami/wordpress” folder. Similarly, the MariaDB data is symbolically linked to “/bitnami/mariadb”. However, it’s important to note that … Read more

404 Error after URL update

You might have already done this, but while logged into the admin of your site, go to Settings > General and then review the urls in WordPress Address (URL) and Site Address (URL). If they do not read with the new domain name, then they need to be updated. Once you have the correct urls … Read more

Add text/link next to the last word of each post

If your site or post type doesn’t use Gutenberg, this is likely because of the wpautop function: it is applied with priority 10 on the_content filter, so the paragraph tags have already been added by the time your filter is running. Changing your callback’s priority to be less than 10 will likely solve your issue. … Read more