wordpress base url – how to get the base url in PHP?
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’).
Example:
define('BASE_URL', get_bloginfo('url'));
echo BASE_URL;
echo "<br> Using get_site_url => ".get_site_url();
echo "<br> Using site_url => ".site_url();
echo "<br> 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.webronix.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
<script type="text/javascript">
var baseurl = '<?php echo get_bloginfo("url"); ?>';
var tplurl = '<?php echo get_bloginfo("template_directory"); ?>';
</script>
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.webronix.com/bogs”, it will return “blogs”
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( '/' );
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;
}
I hope you get an idea about wordpress base url.