Skip to content

Instantly share code, notes, and snippets.

@frankyonnetti
Last active February 17, 2021 00:26
Show Gist options
  • Select an option

  • Save frankyonnetti/6d1bb339084c6b10a1d9fefc93384376 to your computer and use it in GitHub Desktop.

Select an option

Save frankyonnetti/6d1bb339084c6b10a1d9fefc93384376 to your computer and use it in GitHub Desktop.
WordPress - if blog list page #wordpress #list
<?php
/**
* https://codex.wordpress.org/Conditional_Tags#The_Blog_Page
* There is no conditional tag for the blog list page. You have to use
* both `is_home()` and `is_front_page()` to detect this page. You also
* have to use them in the right order to avoid bugs and to test every
* user configuration.
*/
if (is_front_page() && is_home()) {
echo 'default homepage'; // default homepage
} elseif (is_front_page()) {
echo 'static homepage'; // static homepage
} elseif (is_home()) {
echo 'blog list page'; // blog list page
} else {
echo 'everything else'; // everything else
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment