Blog Posts vs Static Page (conditional statements)

Ok, I solved the question, after all. The comments are into the code:

global $paged;
switch ( true ) {

    // Determine if the blog is a static page (subpages)
    case ( is_home() && 'page' && ! is_front_page() && $paged > 1 ) :
        break;

    // Determine if the blog is a static page (first page)
    case ( is_home() && 'page' && ! is_front_page() ) :
        break;

    // Determine if it's the front page and displays the blog (subpages) 
    case ( is_home() && 'posts' && $paged > 1 ) :
        break;

    // Determine if it's the front page: blog and static (both)
    case ( is_front_page() ) :
        break;
}

That’s very useful, for example, if we want to display the blog page in the front page and, at the same time, we want to disable the indexation of the subpages because we already have the categories archives (to avoid duplicate content).

Leave a Comment