[wp-hackers] map file path to url in PHP/WordPress

Dion Hulse (dd32) wordpress at dd32.id.au
Sat Oct 22 01:34:49 UTC 2011


If you're referring to the file from within a plugin, you'd use something
such as:
echo plugins_url('mystyle.css', __FILE__); (The __FILE__ part makes it refer
to mystyle.css relative to the current file)

If you were refering to a themes file, you'd use something such as:
echo get_template_directory_uri() . '/some-style-file.css';

On 22 October 2011 12:31, 肖晗 <xiaohan2012 at gmail.com> wrote:

> Hi guys,
>
> I do not know how to map file path to url in PHP/WordPress.
>
> Suppose my css sheet is in path
>
> /var/www/wordpress/wp-content/plugins/my-plugin/mystyle.css.
>
> And suppose my domain is domain.com.
>
> How can I map the path
>
> /var/www/wordpress/wp-content/plugins/my-plugin/mystyle.css
>
> to
>
> http://domain.com/wordpress/wp-content/plugins/my-plugin/mystyle.css
>
> Any useful functions and Wordpress API will be appreciated
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list