WordPress.org

Ready to get started?Download WordPress

Forums

Plugin Path (3 posts)

  1. davosian
    Member
    Posted 7 years ago #

    I would like to embed an image in my plugin (widget). The image resides in the plugin folder (wp-content/plugins/myplugin/image.gif). How can I reference the image from within my plugin without hardcoding the path?

    Is there something like get_plugin_directory()?

    Thank you,
    Dennis

  2. Kafkaesqui

    Posted 7 years ago #

    Typical ways to accomplish this:

    ABSPATH . 'wp-content/plugins/myplugin/image.gif'

    ABSPATH is a WP constant that provides the full directory path to the (WordPress) installation directory.

    For providing the url, you could use:

    get_settings('siteurl') . '/wp-content/plugins/myplugin/image.gif'

  3. iamfletch
    Member
    Posted 6 years ago #

    i did this :)
    define('PLUGINPATH', ABSPATH.'wp-content/plugins/myplugin');

    and this,

    define('PLUGINLINK', get_settings('siteurl') . 'wp-content/plugins/wpajax/');

Topic Closed

This topic has been closed to new replies.

About this Topic