Articles of paths

Relative URLs within site

I want to link to a page inside a website so the url I want to link to is this: http://www.example.org/about-us/team when I set a link like that: <a href=”about-us/team”>Our Team</a> It doesnt work. I get to the site: http://about-us/team Is there a solution to that? The reason why is because after the Website is […]

php – Plugin/theme relative PATH/URI

I would like to get relative path from a php file without knowing the absolute path. I have succeeded to do it but for a reason which I don’t know, on some servers (in rare case) it doesn’t work when I enqueue css/js. Slashes are missing… Here the code: define(‘PATH’, trailingslashit(str_replace(‘\\’, ‘/’, dirname(__FILE__)))); define(‘URI’, site_url(str_replace(trailingslashit(str_replace(‘\\’, […]

Plugin base URL

In a question that is related to, but not the same as, How to link to images in my plugin regardless of the plugin folder's name plugin-folder/plugin-main-file.php plugin-folder/images/ containing all images plugin-folder/classes/ containing class definitions plugin-folder/classes/class1-files containing additional files for class 1 plugin-folder/classes/class2-files containing additional files for class 2 etc To access images, I can […]

get_attached_file returns wrong path after changing media upload dir

I’ve changed the default WordPress media upload dir (http://example.com/wp-content/uploads) to (http://example.com/uploads). Everything is OK and media files are uploading and showing correctly. But when I use get_attached_file function to get the path of the file (e.g. http://example.com/uploads/hello.jpg), it returns the wrong path ( in this case: home/username/public_html/wp-content/uploads/hello.jpg). So when I call the file_get_contents with this […]

What setting should I configure to move new site folder?

I have a live site and a new wordpress site. The new wordpress site is ready to replace the live site. I want to move the new site folder /public_html/wordpressnewsite to /public_html/ but I afraid the path image url can’t change from http://example.com/wordpressnewsite/wp-content/uploads/2016/07/jj11.jpg to http://example.com/wp-content/uploads/2016/07/jj11.jpg What is the correct way to move the site? What […]

How to have a custom URI path for specific page template

I have a custom template file called page_system.php. I have a page in WordPress called “System” which uses this template. The path to view this page is: www.mysite.com/system/ I want a way via htacess or otherwise, that would allow me to add anything after the path and put it in a get variable, so that […]

Correct Plugin File Path

Warning: require_once(/assets/MCAPI.class.php): failed to open stream: No such file or directory in /home2/……/wp-content/plugins/bplugin/shortcodes.php on line 148 Fatal error: require_once(): Failed opening required ‘/assets/MCAPI.class.php’ (include_path=’.:/opt/php54/lib/php’) in /……./wp-content/plugins/bplugin/shortcodes.php on line 148 require_once(plugin_dir_path( __FILE__ ) . ‘/assets/MCAPI.class.php’); Am I not using the correct path method? This file is called inside a rest API function → https://www.screencast.com/t/5mhWur8hmR Update: If […]

Hardcoded paths in my plugin

Sorry for the stupid question: I’m trying to create a basic plugin and from its main file I want to refer files in two directories that are in the same directory as the main plugin. I tried to reference them this way: plugin_dir_path( __FILE__ ).’js/my.js’ or plugin_dir_path( __FILE__ ).’imgs/myImg.jpg’ but it crearly creates a path […]

Apply template by path/slug related to custom post type?

I have a custom post type called “project” and an accompanying single view template labeled single-project.php On the landing page for each project, I have sub-navigation that points to separate sub-sections that query related items such as “Related Projects” and “Related Resources”. Is there a way I can create templates to handle these pages based […]

Images give 404 after changing default domain

Never encountered this issue before. So I’ve just moved a site for a client to another server and for some reason all images give me a 404 when I change the default domain in the database (siteurl and home). CSS, JS and other files are linked correctly – it seems there’s something affecting the uploads […]