Thursday, November 10, 2022

Detect current URL and match with home page in wordpres

Detect current URL and match with home page in wordpres:

Sometimes you may select "Your latest posts" in backend settings->reading.

In this case your home page will be your theme's index.php file.

In this case you might need to detect what is your front page / home page and match to your current page.

In this case you can use below code to differentiate home page to other pages/posts:

$home_url = get_option('home') . '/';
$actual_link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'
? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";

if ($home_url === $actual_link) {
    // Code goes here
}

// Happy coding...

Workflow of WordPress project in a team with Git

1. We should not push any Wordpress core folders or files to github. 2. Only push custom theme and custom plugin into github. 3. So, in this...