wordpress base url – how to get the base url in PHP?

wordpress base url – You can get WordPress Get site URL in PHP : Using get_site_url(), Using site_url() and get_bloginfo(‘url’).

wordpress base url – Getting Base URL in WordPress

wordpress base url – wordpress Get Absolute Path, Document Root, Base URL. get a “base URL” in WordPress within a template file?
Example

define('BASE_URL', get_bloginfo('url'));

echo BASE_URL;

echo "
Using get_site_url => ".get_site_url(); echo "
Using site_url => ".site_url(); echo "
Using get_bloginfo => ". get_bloginfo('url');

What is: Absolute Path

Example : get current theme absolute path wordpress

/home/ridham/www/pakainfo/index.php
C:\Windows\Users\ridham\html\docs\pakainfo\index.php

Retrieve WordPress root directory path?

if ( !defined('ABSPATH') )
    define('ABSPATH', dirname(__FILE__) . '/');

wordpress get domain

// WORDPRESS GET SITE URL:
echo get_site_url(); // echo's http://www.pakainfo.com

wordpress get base url

wordpress get site url

$url = site_url();
echo $url;

current url wordpress

global $wp;
echo home_url( $wp->request )

wordpress get domain

// WORDPRESS GET SITE URL:
echo get_site_url(); // echo's http://www.infinityknow.com

get Bloginfo baseurl in JavaScript File


Get current page URL in WordPress

global $wp;
$current_url = home_url( add_query_arg( array(), $wp->request ) );

WordPress get current URL with parameters
For example if your website is “https://www.apakinfo.com/tamil-rokers”, it will return “tamil-rokers”

global $wp;
$current_slug = add_query_arg( array(), $wp->request );

Get current URL in WordPress on specific PHP templates

$resData = get_queried_object_id();
$current_url = get_permalink( $resData );

$resData = get_queried_object_id();
$current_url = get_term_link( $resData );

$resData = get_queried_object_id();
$current_url = get_author_posts_url( $resData );

$current_url = home_url( '/' );

Don’t Miss : Get The Full URL In WordPress

Get A WordPress Plugin File Path Or URL

1: how to get plugin directory path in wordpress

$dir = plugin_dir_path( __DIR__ );

2: how to get plugin directory path in wordpress

if ( is_admin() ) {
    include_once( plugin_dir_path( __FILE__ ) . 'includes/admin-functions.php' );
} else {
    include_once( plugin_dir_path( __FILE__ ) . 'includes/front-end-functions.php' );
}

3: how to get plugin directory path in wordpress

define( 'MY_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
include( MY_PLUGIN_PATH . 'includes/admin-page.php');
include( MY_PLUGIN_PATH . 'includes/classes.php');
// etc.

4: how to get plugin directory path in wordpress

function plugin_dir_path( $file ) {
    return trailingslashit( dirname( $file ) );
}

how to get plugin directory path in wordpress

foreach ( glob( plugin_dir_path( __FILE__ ) . "subfolder/*.php" ) as $file ) {
    include_once $file;
}

Also Read Get Current Plugin URL In WordPress

I hope you get an idea about wordpress base url.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment