Search
Close this search box.

How to add a custom URL to the My Account menu in any position

Amitpal Singh
Amitpal Singh
October 25, 2021

Add Custom URL in My Account menu in any position in woocommerce

function misha_one_more_link( $menu_links ){
 
	// we will hook "anyuniquetext123" later
	$new = array( 'postad' => 'Post Ad' );
 
	// or in case you need 2 links
	// $new = array( 'link1' => 'Link 1', 'link2' => 'Link 2' );
 
	// array_slice() is good when you want to add an element between the other ones
	$menu_links = array_slice( $menu_links, 0, 1, true ) 
	+ $new 
	+ array_slice( $menu_links, 1, NULL, true );
 
 
	return $menu_links;
 
 
}
add_filter ( 'woocommerce_account_menu_items', 'misha_one_more_link' );
 
/** Add My Account Menu Links with Custom URLs **/
function misha_hook_endpoint( $url, $endpoint, $value, $permalink ){
 
	if( $endpoint === 'postad' ) {
 
		// ok, here is the place for your custom URL, it could be external
		$url = site_url().'/post-listing/';
 
	}
	return $url;
 
}
add_filter( 'woocommerce_get_endpoint_url', 'misha_hook_endpoint', 10, 4 ); 

Share this post:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.