I'm working on a wordpress plugin, and I need to change the Login menu name to My Account when the user is logged in.
I also need to change the title of the page. I've tried using the filter below, but it ends up changing all the links in the site.
add_filter('the_title', 'function_name');
And how much to change the name of the menu, I did not find anything about it, does anyone have any suggestions about something?
Thank you in advance ...
THE CODE
Trying to add a shortcode to be used as above!
if ( !function_exists('custom_login_form') )
{
function custom_login_form()
{
$args=array(
"echo" => false,
"label_log_in" => "Entrar",
"remember" => true,
);
if ( !is_user_logged_in() ){
return wp_login_form($args);
}else{
return 'Logado em Minha conta! <br />' . wp_loginout('index.php');
}
}
}
add_shortcode('login_form', 'custom_login_form');
This works perfectly, I would now like to make changes to the menu and page title!
RESOLUTION
After many searches I was able to find a solution to the problem, which by coincidence I had tried and did not work at all.
Using the following filter.
add_filter('wp_nav_menu_items', 'function_name', 10, 2);
function func_name_wp_nav($items, $args){
return $items;
}
Then you add items according to the menu, which is usually LI it adds as the last element, example.
$item .= "<li><a href='#'>Item 1</a></li>";
This worked perfectly for me! Any questions regarding the post, comment and I will try to answer as I know.
Thank you ...