Title: using url in code
Last modified: November 22, 2022

---

# using url in code

 *  Resolved [eamonncoyne](https://wordpress.org/support/users/eamonncoyne/)
 * (@eamonncoyne)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/using-url-in-code/)
 * Hi,
 * I am a new user of _Code Snippets_ as before I was using _My Custom Functions_(
   which was working flawlessly but has been removed from WordPress.org)
 * When using a snippet containing the following type of code:
 * `include_once(dirname(__FILE__) . '/../../../../themes/stockholm/dynamic_page/
   dbconnect_well.php');`
 * I am getting an warning error showing the following where the path to the plugin
   is being added to the above path
 * `Warning: include_once(/home/wellsfor/public_html/wp-content/plugins/code-snippets/
   php/../../../../themes/stockholm/dynamic_page/dbconnect_well.php): failed to 
   open stream: No such file or directory in /home/wellsfor/public_html/wp-content/
   plugins/code-snippets/php/snippet-ops.php(505) : eval()'d code on line 4`
 * Hopefully someone can help with this as for the short term I have had to deactivate
   the snippet and add to functions.php instead
 * Thanks
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fusing-url-in-code%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Shea Bunge](https://wordpress.org/support/users/bungeshea/)
 * (@bungeshea)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/using-url-in-code/#post-16236595)
 * Welcome to the plugin!
 * I recommend using absolute paths when loading files whenever possible.
 * Something like this should work much better:
 * `include_once get_theme_root( 'stockholm' ) . '/dynamic_page/dbconnect_well.php';`
 *  Thread Starter [eamonncoyne](https://wordpress.org/support/users/eamonncoyne/)
 * (@eamonncoyne)
 * [3 years, 5 months ago](https://wordpress.org/support/topic/using-url-in-code/#post-16241236)
 * Hi,
    Didn’t work as was but I added the name of the theme to the path instead
   and it worked. Thanks, Éamonn
    -  This reply was modified 3 years, 5 months ago by [eamonncoyne](https://wordpress.org/support/users/eamonncoyne/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘using url in code’ is closed to new replies.

 * ![](https://ps.w.org/code-snippets/assets/icon.svg?rev=2148878)
 * [Code Snippets](https://wordpress.org/plugins/code-snippets/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/code-snippets/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/code-snippets/)
 * [Active Topics](https://wordpress.org/support/plugin/code-snippets/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/code-snippets/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/code-snippets/reviews/)

## Tags

 * [include_once](https://wordpress.org/support/topic-tag/include_once/)
 * [url](https://wordpress.org/support/topic-tag/url/)

 * 2 replies
 * 2 participants
 * Last reply from: [eamonncoyne](https://wordpress.org/support/users/eamonncoyne/)
 * Last activity: [3 years, 5 months ago](https://wordpress.org/support/topic/using-url-in-code/#post-16241236)
 * Status: resolved