Cho minh xin đoạn code lấy đường dẫn hiện tại đang truy cập của website wordpress như thế nào vậy? lấy toàn bộ đường dẫn ha mọi người, vD: https://itseovn.com/forums/ Bạn nào biết cách lấy cho mình xin đoạn code nhé, cảm ơn mọi người
Bạn có thể sử dụng các code sau để lấy đường dẫn url hiện tại nhé: Mã: $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); Lấy tất cả url cả http và domain. Hoặc code khác mình tham khảo trên web như sau: Mã: function sb_get_current_url() { global $wp; $current_url = trailingslashit(home_url($wp->request)); return $current_url; } Mã: function sb_get_current_url() { if(is_singular()) { return get_permalink(); } else { global $wp; $current_url = trailingslashit(home_url($wp->request)); return $current_url; } } Mã: global $wp; $current_url = home_url(add_query_arg(array(),$wp->request));