Get the full URL in WordPress

php Programming Technology

Today, We want to share with you Get the full URL in WordPress.In this post we will show you wordpress get current admin page url, hear for wordpress multisite get current site url we will give you demo and example for implement.In this post, we will learn about wordpress get current url without parameters with an example.

List of all Google Adsense, VueJS, AngularJS, PHP, Laravel Examples.

Get the full URL in WordPress

There are the Following The simple About Get the full URL in WordPress Full Information With Example and source code.

As I will cover this Post with live Working example to develop Returning current URL in WordPress, so the php – How to get URL of current page displayed? for this example is following below.

PHP ways to grab the current URL

<?php
  $liveURI = "//" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>

Get Current Page URL in WordPress

<?php
  global $wp;
  $liveURI = home_url( add_query_arg( array(), $wp->request ) );
?>

Get current URL (permalink) without /page/{pagenum}/

global $wp;

$liveURI =  home_url( $wp->request ); 

$pos = strpos($liveURI , '/page');

$finalurl = substr($liveURI,0,$pos);


echo $finalurl;

Get current page URL in WordPress

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

/* For example if your website is "https://yourdomain.com/some-post", 
it will return "some-post" */
 
global $wp;
$current_slug = add_query_arg( array(), $wp->request );

Get current URL in WordPress on specific PHP templates

single.php or page.php

$get_object = get_queried_object_id();
$liveURI = get_permalink( $get_object );

taxonomy.php, category.php, tag.php etc

$get_object = get_queried_object_id();
$liveURI = get_term_link( $get_object );
 

author.php

$get_object = get_queried_object_id();
$liveURI = get_author_posts_url( $get_object );

front-page.php or home.php

$liveURI = home_url( '/' );

Web Programming Tutorials Example with Demo

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Get the full URL in PHP WordPress.
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.


Related FAQ

Here are some more FAQ related to this Article:

  1.   AngularJS Get Current Date Time Example
  2.   URL Redirect in Laravel Tutorial
  3.   Multiple Ternary Operator in php Examples
  4.   Laravel 6 Bootstrap Toggle Switch With Ajax Update To Mysql
  5.   PHP - How to Get current url using CodeIgniter controller's URL from a view
  6.   jQuery Multiple Class Selectors Match Examples
  7.   jQuery Check Uncheck All Checkbox Examples
  8.   jQuery Time Range slider Get Value using JavaScript
  9.   codeigniter print last query - PHP Examples
  10.   jQuery Time Duration Picker Example

Leave a Reply

Your email address will not be published. Required fields are marked *