5
votes
When moving a WP site, why does wp-admin redirect to old site?
It is not a big problem. Your Database contains all previous links which cannot be automatically converted. There are two type of solutions for that:
In wp-config.php add this code:
define('WP_HOME',...
4
votes
Accepted
How to get path or root of plugin folder, not file or dir?
How about just define a constant that stores the plugin's root path?
Define path constant
For calling numerous files, it is sometimes convenient to define a
constant:
define( 'MY_PLUGIN_PATH', ...
4
votes
Accepted
Hook filter to change wp_upload_dir() path in multisite
Use the upload_dir filter.
add_filter( 'upload_dir', 'wpse_261931_upload_dir', 10, 1 );
function wpse_261931_upload_dir( array $uploads ) {
if( is_multisite() ) {
//* Do something interesting ...
3
votes
Accepted
Migrating a File from Plugin to Theme and changing its path → instead create a REST endpoint
I'm not sure why are you trying to print out a PHP file's path, because it's not a good practice. But to get the equivalent function for themes, you can use:
For parent themes : ...
2
votes
When moving a WP site, why does wp-admin redirect to old site?
Just changing the site URL in the config will likely not update all of the internals to create a working dev site for you (unless the site is pretty bare-bones). You'll have problems with serialized ...
2
votes
How to have a custom URI path for specific page template
You need to add a rewrite rule to WordPress. There are several options to do it depending on your exact needs.
Maybe the most general is using add_rewrite_tag() and add_rewrite_rule():
add_action( '...
2
votes
How to inject custom url path for page ?
you can use this plugin to generate this kind of permalink https://wordpress.org/plugins/wp-category-permalink/
2
votes
Accepted
Changing the server path
WordPress doesn't rely on server path, it relies on the URI. When the WordPress code is loaded, it will define the proper paths itself dynamically by using PHP constants like __FILE__, such as ABSPATH ...
2
votes
path of wp-content directory when we are on some plugin
Just use pre-defined constant
echo WP_CONTENT_DIR;
2
votes
How much control do we have over CPT rewrite slugs? Can I create a "root" page for my CPT with out the page path, and then have paths for other pages?
The way I see it, you could do:
// Via the init hook, do all these:
register_post_type( 'library-books', [
'public' => true,
'label' => 'Library Books',
'rewrite' =&...
2
votes
Accepted
Add custom path to url to specific pages
If you want to change the permalink structure for all Pages (i.e. posts of the page type), you can use the WP_Rewrite::$page_structure property like so:
add_action( 'init', 'wpse_382911' );
function ...
2
votes
Components used in Themes and Plugins: How to get file URL?
Is there a way to determine if my current PHP file is within the plugins' folder or within the themes' folder
Broadly you always have path to current file (__FILE__) so you can always examine it for ...
2
votes
Is there a way to get a path to the theme directory without the server name?
Yes get_template_directory:
get_template_directory(): string
Retrieves template directory path for the active theme.
Returns an absolute server path (eg: /home/user/public_html/wp-content/themes/...
1
vote
Pulling images from a subdomain
Managed to solve it myself..
So if anyone else has this problem.
Because the sub-domain is still under the main domain you do not have to put -
/home/hostname/subdomain.com
you only need the
/home/sub-...
1
vote
specifying relative file paths in WP with jQuery requests not working
In PHP, it's not necessary to post to a PHP file, it is only required to include ( or require ) files and then use checks and validations to ensure that code is only processed when required.
You ...
1
vote
Accepted
Plugin path comes wrongly
To solve this problem, we must use plugin_dir_url command.
For example:
<?php
wp_register_style( 'foo-styles', plugin_dir_url( __FILE__ ) . 'dahili/bootstrap.min.css' );
...
1
vote
Accepted
How can I get a link path to use for my resources such as JS scripts?
Although @butlerblog's answer works, I find it unecessarily complex. I've checked above and beyond, site_url will always give you the current site's link, it will resolve the schemas for you, whether ...
1
vote
How can I get a link path to use for my resources such as JS scripts?
This is kind of a hacky way to do this; but unfortunately, there is not a WP function that will do both (theme and/or plugin). It's only an either/or proposition.
On the surface, you'd think it ...
1
vote
Accepted
How to get post image root URL?
The get_attached_file() function returns the path to a file based on the attachment ID:
$FeaturedImage = get_attached_file( get_post_thumbnail_id() );
Getting the path to a specific size is more ...
1
vote
What is procedure to let set path in wordpress?
[jsmol acc='caffeine' type='mol']
Will look for an uploaded file named caffeine.mol. If it can't find a matching post for an uploaded attachment and type=pdb, it will try http://rcsb.org/pdb. If it ...
1
vote
Accepted
Apply template by path/slug related to custom post type?
You can't set a project as a base of permalink because you would have to enter rewrite rules for each one.
What you can do is create a custom taxonomy related-resources:
function ...
1
vote
Theme in wp-content but my index.php search theme files in root
I assume you are adding your stylesheets like this in your header:
<link rel="stylesheet" type="text/css" href="css/style.css">
Which won't work. To construct the path dynamically, you need to ...
1
vote
Back button to previous page and breadcrumbs
For the button behavior,
If it's a one-off use case, you could add custom php conditional to check the referring url $_SERVER['HTTP_REFERER'] and current page/post ID or url. Then, either add a ...
1
vote
Accepted
Correct Plugin File Path
https://developer.wordpress.org/reference/functions/plugin_dir_path/
It looks like this function adds a trailing slash, so starting your string with a slash is not required try;
require_once(...
1
vote
Accepted
Hardcoded paths in my plugin
You want to use plugin_dir_url():
$url = plugin_dir_url( __FILE__ ) . 'js/my.js';
1
vote
Components used in Themes and Plugins: How to get file URL?
Here's a solution that will return the URL to a file relative to its location, as well as string indicating where the file lives, i.e. mu-plugins/plugins/theme.
This code has been adapted from ...
1
vote
How to inject custom url path for page ?
For a page, you need to create a parent page(s) with the slug you want to put in between. Then you may choose these pages as a parent to the last slug page (insight page in your case). It will insert ...
1
vote
How to inject custom url path for page ?
It's probably best to register a new post type for this. In custom post types you can easily control the url structure. Use the register_post_type function for this.
In this function you can add a ...
1
vote
Plugin base URL
Sorry for the late answer, below is the function I use to retrieve the plugin directory name in the format requested by @Andrew (i.e. with a trailing slash as mentioned in the comment to Kevin)
/**
* ...
1
vote
When moving a WP site, why does wp-admin redirect to old site?
phpMyAdmin: go to wp_options table set homeurl and siteurl as your new url
Login to you wp-admin dashboard go to setting->general
change WordPress Address (URL) and Site Address (URL)
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
paths × 131plugins × 27
urls × 16
images × 15
directory × 14
plugin-development × 13
php × 11
uploads × 7
themes × 6
url-rewriting × 6
wp-enqueue-script × 6
custom-post-types × 5
permalinks × 5
javascript × 5
wp-admin × 5
html × 5
theme-development × 4
htaccess × 4
page-template × 4
media-library × 4
include × 4
breadcrumb × 4
posts × 3
functions × 3
multisite × 3