URLを取得する関数をまとめたものです。

home_url() Home URL http://www.example.com
site_url() Site directory URL http://www.example.com OR http://www.example.com/wordpress
admin_url() Admin directory URL http://www.example.com/wp-admin/
includes_url() Includes directory URL http://www.example.com/wp-includes/
content_url() Content directory URL http://www.example.com/wp-content/
plugins_url() Plugins directory URL http://www.example.com/wp-content/plugins/
get_stylesheet_directory_uri
get_template_directory_uri
get_theme_root_uri
theme_url Themes directory URL https://core.trac.wordpress.org/ticket/18302(Improve child theme file inheritance by introducing `theme_url` to locate a file URI)
get_locale_stylesheet_uri ローカライズスタイルシートのURL http://example.com/wordpress/wp-content/themes/example_theme/ja.cssがあれば、URLをリターンなければ、{$wp_locale->text_direction}.cssがあれば、リターンそれもなければ、沈黙
discover_pingback_server_uri
get_page_uri
get_theme_data
wp_logout_url
wp_lostpassword_url
wp_login_url
wp_nonece_url
trackback_url
network_site_url
network_admin_url
network_home_url
edit_bookmark_link
edit_comment_link
edit_post_link
edit_tag_link
the_author_posts_lilnk
cancel_comment_reply_link
comment_author_email_link
comment_author_link
comment_author_rss
comment_author_url
comment_author_url_link
comment_reply_link
comment_text
comments_link
comments_popup_link
comments_rss_link
next_comments_link
paginate_comments_links
permalink_comments_rss
previous_comments_link
the_permalink
user_trailingslashit
permalink_anchor
get_permalink
get_post_permalink
post_permalink
get_page_link
get_attachment_link
wp_get_attachment_image_src
get_month_link
get_day_link
get_year_link
get_author_posts_url
wp_upload_dir
wp_get_upload_dir

Current URL

function current_url() {
 $pageURL= 'http';
 if( !isset( $_SERVER["HTTPS"] ) ) { $_SERVER["HTTPS"]= ''; } 
 
 if ($_SERVER["HTTPS"]== "on") {$pageURL .= "s";}
 $pageURL .= "://";
 if ($_SERVER["SERVER_PORT"] != "80") {
 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
 } else {
 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 }
 return $pageURL;
}

Relative URL

$url= home_url($path= 'example', $scheme= relative);
echo $url;
site_url( 'dashboard', 'relative' );
admin_url( 'admin-ajax.php', 'relative' );

wp_make_link_relative

function wp_make_link_relative( $link ) {
	return preg_replace( ' |https?://[^/]+(/.*) |i', '$1', $link );
}

WordPress current_url

パーマリンクデフォルト以外

global $wp;
echo esc_url( get_home_url( '', $wp->request ) );

パーマリンクがデフォルトの場合

$current_url= add_query_arg( $wp->query_string, '', home_url( $wp->request ) );

echo esc_url( $current_url );

get post id from URL

$postid= url_to_postid( $url )

get category archive link

<?php get_category_link( $category_id ); ?>