I want to get my account page's endpoint, language independent. get_permalink
code generates proper link " https://example.com/my-account/ ", but I have problems extracting the last part, in eng version "my-account". Echo line which I put for troubleshooting, doesn't generate anything.
$my_acc = explode( '/', get_permalink( get_option( 'woocommerce_myaccount_page_id')));
echo end($my_acc);
Use rtrim
first to remove last /
$url = get_permalink( get_option( 'woocommerce_myaccount_page_id'));
$url = rtrim($url , '/');
$my_acc = explode( '/', $url);
echo end($my_acc);
Demo with /
: https://eval.in/1094094 Demo without /
: https://eval.in/1094096
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.