How can I get the current plugin directory in WordPress?

How can I get the current plugin directory in WordPress?

How can I get the current plugin directory in WordPress?

How can I get the current plugin directory in WordPress?
If you want to get the current directory path within a file, you can use the magic constants __FILE__ and __DIR__ with the plugin_dir_path() function as: $dir_path = plugin_dir_path( __FILE__ ); CurrentDirectory Path: /home/user/var/www/wordpress_site/wp

wordpress各种获取路径和URL地址的函数总结-菜鸟笔记
返回当前WordPress站点存放核心文件的目录wp-includes的地址,可以带一个$path作为参数。 返回WordPress上传目录的地址,是一个数组,包含一系列与上传地址相关的信息。 提供如下信息给你. 'error' – 报错信息.

php – How to get URL of current page displayed? – WordPress Development …
You may use the below code to get the whole current URL in WordPress: global $wp; $current_url = home_url(add_query_arg(array(), $wp->request)); This will show the full path, including query parameters.

WordPress各种获取路径和地址的函数或常量总结 – themebetter
返回当前WordPress站点存放核心文件的目录wp-includes的地址,可以带一个$path作为参数。 返回WordPress上传目录的地址,是一个数组,包含一系列与上传地址相关的信息。 提供如下信息给你. 'error' – 报错信息. 如果当前启用的主题是一个child theme,该函数返回parent theme的主题目录URI,用法与get_stylesheet_directory_uri ()类似。 如果当前启用的主题是一个child theme,该函数返回parent theme的主题目录的服务器绝对路径,用法与get_stylesheet_directory ()类似。

Get the current URL in WordPress | Matthew Spencer
Sometimes you need to get the current URL (or path) in WordPress outside the loop (e.g. when a post ID is unavailable like on archive pages). There are different ways of handling this — constructing the URL using $_SERVER or the global $wp object — but I

WordPress函式:get_current_site – 閃電博 – 闪电博
get_current_site: 這個函式返回一個物件,代表WordPress多站點網路中的當前站點。它包括網站的名稱、URL和管理員的電子郵件地址等資訊。

wordpress各种获取路径和URl地址的函数总结 – xiaobingch …
返回当前WordPress站点存放核心文件的目录 wp-includes 的地址,可以带一个 $path 作为参数。 返回WordPress上传目录的地址,是一个数组,包含一系列与上传地址相关的信息。 提供如下信息给你. 'error' – 报错信息. 例如. 获取存放主题的目录URI. 获取存放主题的目录的服务器绝对路径. 获取主题目录的目录名称,如果你的主题目录是 /wp-content/themes,则. 获取当前启用的主题目录的服务器绝对路径,例如. 可以用来include文件,例如. <?phpinclude ( get_stylesheet_directory () . '/includes/myfile.php'); ?> 获取当前启用的主题目录的URI,例如.

php – Returning current URL in WordPress – Stack Overflow
Depending on where you are calling your URL you could try get_the_permalink() but a more surefire way would be to use the $wp->request method. Like this: global $wp; echo home_url( $wp->request )

wordpress – Get URL of the current file with PHP – Stack Overflow
Since you're working in WordPress, the WordPress-specific way of doing this is to use get_stylesheet_directory_uri(). It will return the URL for the current theme (or child theme). See https://developer.wordpress.org/reference/functions/get_stylesheet_directory_uri/ for full details.

plugin_dir_path() – Function | Developer.WordPress.org
If you want the get the path one level up from the current dir, you can do //current path: /home/user/var/www/wordpress/wp-content/plugins/my-plugin/ $dir = plugin_dir_path( __DIR__ ); //$dir is set to /home/user/var/www/wordpress/wp-content/plugins/

Previous Article

Donate to The Salvation Army - Donate Today

Next Article

Lee Seo Jin: Royal Descendant, Relationship with Beckham, and Lovelife ...