I work on small project, and want to make this scenario to work on. I want to make when user is logged in the title of My Account page to write "My Account", and when is logged out, the title of page to write "Login Register". To explain better with images:
I have this code apply, but it seems do not change something.
function dynamic_label_change( $items, $args ) {
if ( ! is_user_logged_in() ) {
$items = str_replace( "My Account", "Account Login / Register ", $items );
}
return $items;
}
or maybe
// When user is on my account page and not logged in
if (is_account_page() && !is_user_logged_in()) {
echo '<h1 class="entry-title">'.__("My custom title",
"the_theme_slug").'</h1>'; // My custom title
} else {
the_title( '<h1 class="entry-title">', '</h1>' ); // the normal template
title
}
Any help?
You can use the following:
add_filter( 'the_title', 'display_product_image_in_order_item' );
function display_product_image_in_order_item( $title ) {
if( is_account_page() && $title === __('My Account', 'woocommerce') && ! is_user_logged_in() ) {
$title = __( 'Account Login / Register', 'woocommerce' );
}
return $title;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.